0

So.. Ive been building an application with Symfony3 framework for my bachelor project and it works flawless on localhost. Both in dev-environment and prod.

However. When Im trying to deploy it to a Heroku App im getting the following log..

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: Class 'Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle' not found in /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/app/AppKernel.php:15
   Stack trace:
   #0 /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(396): AppKernel->registerBundles()
   #1 /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(114): Symfony\Component\HttpKernel\Kernel->initializeBundles()
   #2 /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()
   #3 /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(118): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvI in /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/app/AppKernel.php on line 15
   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: Class 'Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle' not found in /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/app/AppKernel.php:15                                                                                                                                                              
     Stack trace:                                                                                                                                                                                                                                                                                                                                                      
     #0 /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(396): AppKernel->registerBundles()                                                                                                                                                                                    
     #1 /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(114): Symfony\Component\HttpKernel\Kernel->initializeBundles()                                                                                                                                                        
     #2 /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\Component\HttpKernel\Kernel->boot()                                                                                                                                                       
     #3 /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php(118): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvI in /tmp/build_68991520ff4642cdf86248159a2f0f54/Carante-getmoving-585074f/app/AppKernel.php on line 15  
     .                                                                                                                                                                                                                                                                                                                                                                 


   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

Or at least this is where it starts to go wrong.

My AppKernel.php file looks like this..

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

    class AppKernel extends Kernel
    {
        public function registerBundles()
        {
            $bundles = [
                new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
                new Symfony\Bundle\SecurityBundle\SecurityBundle(),
                new Symfony\Bundle\TwigBundle\TwigBundle(),
                new Symfony\Bundle\MonologBundle\MonologBundle(),
                new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
                new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
                new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
                new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
                new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
                new AppBundle\AppBundle(),
            ];

            if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
                $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
                $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
                $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
                $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
                $bundles[] = new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle();
            }

            return $bundles;
        }

If I comment out the Swiftmailer class in AppKernel, another class is causing the exact same issue.

I hope theres someone here who can help me out or at least to understand the error a bit more.

Truth be told, deploying applications and handling anything serverside is not my strongest site so im in pretty deep water.

Thanks... :)

5
  • 1
    Have you looked at this at all: symfony.com/doc/current/deployment/heroku.html Commented Dec 12, 2016 at 3:29
  • Try after updating composer. that might be solve the issue Commented Dec 12, 2016 at 4:31
  • @AlvinBunk Yes i have gone through both the symfony tut and the heroku one, but it seems like I'm missing some configurations or something which i cannot figure out...? Commented Dec 12, 2016 at 9:27
  • @GopalJoshi That is what I stumbled upon now as well. But when Im updating i get the following error: Content-Length mismatch http://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date Commented Dec 12, 2016 at 9:59
  • please check permission of cache folder. Reference github.com/composer/composer/issues/3470 Commented Dec 12, 2016 at 11:05

2 Answers 2

0

I'm beginning to think it's a file permission issue as well like Gopal. Here's the documentation on file permissions that need to be set:

https://symfony.com/doc/current/setup/file_permissions.html

Heroku is a bit different, so I don't have any guidance on that since I haven't tried it before.

Sign up to request clarification or add additional context in comments.

1 Comment

I've commented your suggestion with an "answer"
0

@AlvinBunk I've reensured the permissions in the various folders and established a much more stable internet connection and the previous composer update error is now gone..

However.. Now i get the same error as i do when I'm trying to deploy the app.

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:                                                                                                             
  Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SwiftmailerBundle" from namespace "Symfony\Bundle\SwiftmailerBundle".        
  Did you forget a "use" statement for another namespace? in /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/app/AppKernel.php:16                      
  Stack trace:                                                                                                                                                                          
  #0 /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(396): AppKernel->registerBund  
  les()                                                                                                                                                                                 
  #1 /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(114): Symfony\Component\HttpK  
  ernel\Kernel->initializeBundles()                                                                                                                                                     
  #2 /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\C  
  omponent\HttpKernel\Kernel->boot()                                                                                                                                                    
  #3 /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getm in /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/app/AppKernel.php on l  
  ine 16                                                                                                                                                                                
  PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "SwiftmailerBundle" from namespace "Symfony\Bundle\SwiftmailerBundle".   
  Did you forget a "use" statement for another namespace? in /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/app/AppKernel.php:16                      
  Stack trace:                                                                                                                                                                          
  #0 /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(396): AppKernel->registerBund  
  les()                                                                                                                                                                                 
  #1 /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(114): Symfony\Component\HttpK  
  ernel\Kernel->initializeBundles()                                                                                                                                                     
  #2 /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php(68): Symfony\C  
  omponent\HttpKernel\Kernel->boot()                                                                                                                                                    
  #3 /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getm in /Users/carante/KEA/WebDeveloping/3. Semester/Bachelor/Application/getmoving-fiji/app/AppKernel.php on l  
  ine 16                                                                                                                                                                                
  .       

3 Comments

Have you contacted Heroku support? Or maybe you have a free account? I'm not sure how support works. I still suspect a file permissions problem.
So. It works now. I deleted and unhooked the swiftmailer bundle everywhere and i succesfully deployed. Afterwards i reenabled and isntalled the bundle again and It seemed like i had an issue with my bundle requirements. I was trying to run composer require swiftmailer/swiftmailer Instead of using composer require symfony/swiftmailer-bundle Thanks for your help though @AlvinBunk
You can help me by upvoting any one of my comments! Glad you got it working!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.