Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony Demo deploying to Heroku with dev environment fails #398

Closed
bocharsky-bw opened this issue Nov 7, 2016 · 6 comments
Closed

Symfony Demo deploying to Heroku with dev environment fails #398

bocharsky-bw opened this issue Nov 7, 2016 · 6 comments

Comments

@bocharsky-bw
Copy link
Contributor

bocharsky-bw commented Nov 7, 2016

Steps to reproduce:

  • Click "Deploy to Heroku" button
  • Change SYMFONY_ENV required variable to dev instead of prod which is by default
  • Press deploy button

Logs

-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
       - php (7.0.12)
       - ext-pdo_sqlite (bundled with php)
       - apache (2.4.20)
       - nginx (1.8.1)
-----> Installing dependencies...
       Composer version 1.2.1 2016-09-12 11:27:19
       Loading composer repositories with package information
       Installing dependencies from lock file
         - Installing doctrine/lexer (v1.0.1)
           Downloading: 100%
       
         - Installing doctrine/annotations (v1.2.7)
           Downloading: 100%
       
         - Installing twig/twig (v1.27.0)
           Downloading: 100%
       
         - Installing symfony/polyfill-util (v1.2.0)
           Downloading: 100%
       
         - Installing paragonie/random_compat (v2.0.2)
           Downloading: 100%
       
         - Installing symfony/polyfill-php70 (v1.2.0)
           Downloading: 100%
       
         - Installing symfony/polyfill-php56 (v1.2.0)
           Downloading: 100%
       
         - Installing symfony/polyfill-mbstring (v1.2.0)
           Downloading: 100%
       
         - Installing symfony/symfony (v3.2.0-BETA1)
           Downloading: 100%
       
         - Installing symfony/polyfill-intl-icu (v1.2.0)
           Downloading: 100%
       
         - Installing psr/log (1.0.1)
           Downloading: 100%
       
         - Installing psr/cache (1.0.1)
           Downloading: 100%
       
         - Installing doctrine/inflector (v1.1.0)
           Downloading: 100%
       
         - Installing doctrine/collections (v1.3.0)
           Downloading: 100%
       
         - Installing doctrine/cache (v1.6.0)
           Downloading: 100%
       
         - Installing doctrine/common (v2.6.1)
           Downloading: 100%
       
         - Installing doctrine/doctrine-cache-bundle (1.3.0)
           Downloading: 100%
       
         - Installing jdorn/sql-formatter (v1.2.17)
           Downloading: 100%
       
         - Installing doctrine/dbal (v2.5.5)
           Downloading: 100%
       
         - Installing doctrine/doctrine-bundle (1.6.4)
           Downloading: 100%
       
         - Installing doctrine/data-fixtures (v1.1.1)
           Downloading: 100%
       
         - Installing doctrine/doctrine-fixtures-bundle (2.3.0)
           Downloading: 100%
       
         - Installing doctrine/instantiator (1.0.5)
           Downloading: 100%
       
         - Installing doctrine/orm (v2.5.5)
           Downloading: 100%
       
         - Installing erusev/parsedown (1.6.0)
           Downloading: 100%
       
         - Installing ezyang/htmlpurifier (v4.8.0)
           Downloading: 100%
       
         - Installing incenteev/composer-parameter-handler (v2.1.2)
           Downloading: 100%
       
         - Installing sensiolabs/security-checker (v4.0.0)
           Downloading: 100%
       
         - Installing sensio/distribution-bundle (v5.0.13)
           Downloading: 100%
       
         - Installing sensio/framework-extra-bundle (v3.0.16)
           Downloading: 100%
       
         - Installing monolog/monolog (1.21.0)
           Downloading: 100%
       
         - Installing symfony/monolog-bundle (2.11.1)
           Downloading: 100%
       
         - Installing swiftmailer/swiftmailer (v5.4.3)
           Downloading: 100%
       
         - Installing symfony/swiftmailer-bundle (v2.3.11)
           Downloading: 100%
       
         - Installing twig/extensions (v1.4.0)
           Downloading: 100%
       
         - Installing pagerfanta/pagerfanta (v1.0.3)
           Downloading: 100%
       
         - Installing white-october/pagerfanta-bundle (v1.0.7)
           Downloading: 100%
       
       Generating optimized autoload files
       > Incenteev\ParameterHandler\ScriptHandler::buildParameters
       Creating the "app/config/parameters.yml" file
       > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
       > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
       PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SensioGeneratorBundle" from namespace "Sensio\Bundle\GeneratorBundle".
       Did you forget a "use" statement for another namespace? in /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/app/AppKernel.php:36
       Stack trace:
       #0 /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(403): AppKernel->registerBundles()
       #1 /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(113): Symfony\Component\HttpKernel\Kernel->initializeBundles()
       #2 /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()
       #3 /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/vendor/symfony/symfony/src/S in /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/app/AppKernel.php on line 36
       Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
       
                                                                                                                                                                                                                            
         [RuntimeException]                                                                                                                                                                                                 
         An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                                                                                          
         PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SensioGeneratorBundle" from namespace "Sensio\Bundle\GeneratorBundle".                               
         Did you forget a "use" statement for another namespace? in /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/app/AppKernel.php:36                                                           
         Stack trace:                                                                                                                                                                                                       
         #0 /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(403): AppKernel->registerBundles()                                  
         #1 /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(113): Symfony\Component\HttpKernel\Kernel->initializeBundles()      
         #2 /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()     
         #3 /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/vendor/symfony/symfony/src/S in /tmp/build_0928389e81d9d8682b8f63075839b766/symfony-symfony-demo-0313e7a/app/AppKernel.php on line 36  
         .                                                                                                                                                                                                                  
                                                                                                                                                                                                                            
       
       install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...
       
 !     Push rejected, failed to compile PHP app.
 !     Push failed

Deploying with prod environment works fine though.

@rendyep
Copy link

rendyep commented Nov 11, 2016

This issue affects me too. Did you solve this problem?

@rendyep
Copy link

rendyep commented Nov 11, 2016

I think it's documented here: https://devcenter.heroku.com/articles/getting-started-with-symfony#configuring-symfony-to-run-in-the-prod-environment

If you don’t explicitly configure the environment (dev, prod etc) to use, Symfony will, by default, use the dev environment in console commands and at runtime. That would break the build, because in dev environments, Symfony uses the SensioGeneratorBundle to perform certain tasks, but that bundle is not installed upon a push - Composer does not install dev packages when pushing to Heroku.

@stof
Copy link
Member

stof commented Nov 11, 2016

If you want to be able to use the Symfony dev env in the deployed version, you will indeed need to move the necessary dependencies to normal requirements rather than dev requirements.

Note however that deploying the Symfony dev environment in a world-accessible deployment is a security issue, because development tools like the WebProfiler can be revealing sensitive info (they are meant to help debugging and so expose lots of info). You should definitely not be using the dev environment on heroku. It is meant for usage on your dev setup locally.

@javiereguiluz
Copy link
Member

Closing it as fixed by #399. A new version of the Symfony Demo app has been tagged, so it'll be available via symfony demo command in a few hours.

@bocharsky-bw
Copy link
Contributor Author

bocharsky-bw commented Nov 13, 2016

@javiereguiluz Actually, #399 does not fix this issue, this one is a bit different. I reused @stof #398 (comment) here and sent another PR #402 to make things clearer. What do you think?

javiereguiluz added a commit that referenced this issue Nov 18, 2016
…sky-bw, javiereguiluz)

This PR was merged into the master branch.

Discussion
----------

Add note about deploying dev environment to Heroku

According to the #398

Commits
-------

00259b7 Tweaked the warning message
5113ee5 Add note about deploying dev environment to Heroku
@zitou54
Copy link

zitou54 commented Mar 29, 2019

hi can you help me i have some probleme bate i don' t have solution
`-----> PHP app detected
-----> Bootstrapping...
-----> Installing platform packages...
- php (7.3.3)
- apache (2.4.38)
- nginx (1.14.2)
-----> Installing dependencies...
Composer version 1.8.4 2019-02-11 10:52:10
Loading composer repositories with package information
Installing dependencies from lock file
Package operations: 56 installs, 0 updates, 0 removals
- Installing doctrine/lexer (v1.0.1): Downloading (100%)
- Installing doctrine/annotations (v1.6.1): Downloading (100%)
- Installing doctrine/reflection (v1.0.0): Downloading (100%)
- Installing doctrine/event-manager (v1.0.0): Downloading (100%)
- Installing doctrine/collections (v1.6.1): Downloading (100%)
- Installing doctrine/cache (v1.8.0): Downloading (100%)
- Installing doctrine/persistence (v1.1.0): Downloading (100%)
- Installing doctrine/inflector (v1.3.0): Downloading (100%)
- Installing doctrine/common (v2.10.0): Downloading (100%)
- Installing doctrine/dbal (v2.9.2): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.11.0): Downloading (100%)
- Installing symfony/polyfill-ctype (v1.11.0): Downloading (100%)
- Installing twig/twig (v2.7.4): Downloading (100%)
- Installing paragonie/random_compat (v9.99.99): Downloading (100%)
- Installing symfony/polyfill-php70 (v1.11.0): Downloading (100%)
- Installing symfony/polyfill-util (v1.11.0): Downloading (100%)
- Installing symfony/polyfill-php56 (v1.11.0): Downloading (100%)
- Installing symfony/symfony (v3.4.23): Downloading (100%)
- Installing symfony/polyfill-intl-icu (v1.11.0): Downloading (100%)
- Installing symfony/polyfill-apcu (v1.11.0): Downloading (100%)
- Installing psr/simple-cache (1.0.1): Downloading (100%)
- Installing psr/log (1.1.0): Downloading (100%)
- Installing psr/link (1.0.0): Downloading (100%)
- Installing psr/container (1.0.0): Downloading (100%)
- Installing psr/cache (1.0.1): Downloading (100%)
- Installing fig/link-util (1.0.0): Downloading (100%)
- Installing doctrine/doctrine-cache-bundle (1.3.5): Downloading (100%)
- Installing jdorn/sql-formatter (v1.2.17): Downloading (100%)
- Installing doctrine/doctrine-bundle (1.10.2): Downloading (100%)
- Installing doctrine/data-fixtures (v1.3.1): Downloading (100%)
- Installing doctrine/doctrine-fixtures-bundle (3.1.0): Downloading (100%)
- Installing doctrine/instantiator (1.2.0): Downloading (100%)
- Installing egulias/email-validator (2.1.7): Downloading (100%)
- Installing friendsofsymfony/user-bundle (dev-master 5d21457): Downloading (100%)
- Installing incenteev/composer-parameter-handler (v2.1.3): Downloading (100%)
- Installing knplabs/knp-components (v1.3.10): Downloading (100%)
- Installing michelf/php-markdown (1.8.0): Downloading (100%)
- Installing composer/ca-bundle (1.1.4): Downloading (100%)
- Installing sensiolabs/security-checker (v5.0.3): Downloading (100%)
- Installing sensio/distribution-bundle (v5.0.24): Downloading (100%)
- Installing monolog/monolog (1.24.0): Downloading (100%)
- Installing symfony/monolog-bundle (v3.3.1): Downloading (100%)
- Installing symfony/polyfill-iconv (v1.11.0): Downloading (100%)
- Installing symfony/polyfill-php72 (v1.11.0): Downloading (100%)
- Installing symfony/polyfill-intl-idn (v1.11.0): Downloading (100%)
- Installing swiftmailer/swiftmailer (v6.2.0): Downloading (100%)
- Installing symfony/swiftmailer-bundle (v3.2.5): Downloading (100%)
- Installing sensio/framework-extra-bundle (v5.2.4): Downloading (100%)
- Installing doctrine/orm (v2.6.3): Downloading (100%)
- Installing vectorxhd/trophy-bundle (V1.0.0): Downloading (100%)
- Installing jms/metadata (2.0.0): Downloading (100%)
- Installing behat/transliterator (v1.2.0): Downloading (100%)
- Installing vich/uploader-bundle (1.9.2): Downloading (100%)
- Installing knplabs/knp-paginator-bundle (v2.7.2): Downloading (100%)
- Installing knplabs/knp-markdown-bundle (1.7.1): Downloading (100%)
- Installing yosimitso/workingforumbundle (V2.0.1): Downloading (100%)
Generating optimized autoload files
> Incenteev\ParameterHandler\ScriptHandler::buildParameters
Creating the "app/config/parameters.yml" file
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
PHP Fatal error: Uncaught Error: Call to undefined function apcu_fetch() in /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcuCache.php:26
Stack trace:
#0 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php(200): Doctrine\Common\Cache\ApcuCache->doFetch('DoctrineNamespa...')
#1 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php(177): Doctrine\Common\Cache\CacheProvider->getNamespaceVersion()
#2 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php(60): Doctrine\Common\Cache\CacheProvider->getNamespacedId('AppBundle\Entit...')
#3 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(177): Doctrine\Common\Cache\CacheProvider->fetch('AppBundle\Entit...')
#4 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/persis in /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcuCache.php on line 26
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception

     [RuntimeException]                                                                                                                                                                                                           
     An error occurred when executing the "'cache:clear --no-warmup'" command:                                                                                                                                                    
                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                  
     PHP Fatal error:  Uncaught Error: Call to undefined function apcu_fetch() in /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcuCache.php:26                                    
     Stack trace:                                                                                                                                                                                                                 
     #0 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php(200): Doctrine\Common\Cache\ApcuCache->doFetch('DoctrineNamespa...')                                        
     #1 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php(177): Doctrine\Common\Cache\CacheProvider->getNamespaceVersion()                                            
     #2 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php(60): Doctrine\Common\Cache\CacheProvider->getNamespacedId('AppBundle\\Entit...')                            
     #3 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/persistence/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(177): Doctrine\Common\Cache\CacheProvider->fetch('AppBundle\\Entit...')  
     #4 /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/persis in /tmp/build_622536e90458d71f10d7c70d1ded344f/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcuCache.php on line 26                                
                                                                                                                                                                                                                                  
   
   install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...

! WARNING: A Composer script terminated with an exception
! ERROR: Dependency installation failed!
!
! The 'composer install' process failed with an error. The cause
! may be the download or installation of packages, or a pre- or
! post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
! in your 'composer.json'.
!
! Typical error cases are out-of-date or missing parts of code,
! timeouts when making external connections, or memory limits.
!
! Check the above error output closely to determine the cause of
! the problem, ensure the code you're pushing is functioning
! properly, and that all local changes are committed correctly.
!
! For more information on builds for PHP on Heroku, refer to
! https://devcenter.heroku.com/articles/php-support
!
! REMINDER: the following warnings were emitted during the build;
! check the details above, as they may be related to this error:
! - A Composer script terminated with an exception
! Push rejected, failed to compile PHP app.
! Push failed`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants