1
votes

I have a bundle in symproject/src/MyAppBundle/src/Bundle

This folder contains MyAppBundle.php:

    <?php

    namespace MyCompany\Action\Provider\MyAppBundle\Bundle;

    use Symfony\Component\HttpKernel\Bundle\Bundle;

    class MyAppBundle extends Bundle
    {
    }

Then I register it in App/Appkernel.php:

 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 AppBundle\AppBundle(),
            new MyCompany\Action\Provider\MyAppBundle\Bundle\MyAppbundle(),
        ];

        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();

            if ('dev' === $this->getEnvironment()) {
                $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
                $bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
            }
        }

        return $bundles;
    }

The site won't work at all after doing this. The log says:

PHP Fatal error: Uncaught Error: Class 'MyCompany\Action\Provider\MyAppProvider\Bundle\MyAppBundle' not found in /var/www/html/symproject/app/AppKernel.php:20\nStack trace:\n#0 /var/www/html/symproject/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(494): AppKernel->registerBundles()\n#1 /var/www/html/symproject/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(134): Symfony\Component\HttpKernel\Kernel->initializeBundles()\n#2 /var/www/html/symproject/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(197): Symfony\Component\HttpKernel\Kernel->boot()\n#3 /var/www/html/symproject/web/app.php(19): Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))\n#4 {main}\n thrown in /var/www/html/symproject/app/AppKernel.php on line 20

1
it seems like that bundle MyCompany\ACtion\Provider\MyAppProvider\Bundle\MyAppBundle is not found, do you have the class already ? did you configure auto-loading for the bundle ?Saif Eddin Gmati
Maybe beacuse the C is capital in ACtion and it is small elsewhereprit.patel
You have issues with paths/namespaces. symproject/src/MyAppBundle/src/Bundle/MyAppBundle.php should be symproject/src/MyAppBundle/MyAppBundle.php and then adjust your namespaces. Or you have to define a psr-4 in your composer. You've messed up something i think.Jack Skeletron
The capital C is a typo rewriting it for Stack overflow.prgrm

1 Answers

1
votes

You've placed bundle class to

symproject/src/MyAppBundle/src/Bundle

folder, but namespace is

MyCompany\Action\Provider\MyAppBundle\Bundle

It should be like namespace

App\MyAppBundle\Bundle

and moved to folder

symproject/src/MyAppBundle/Bundle

Or you should change autoload section of your composer.json file to use different class loading.

https://getcomposer.org/doc/01-basic-usage.md#autoloading