0
votes

I am having a lot of problems with my Symfony project in prod. My last problem is when I try to clean cache:

php bin/console cache:clear --env=prod --no-debug

console return me:

[Symfony\Component\Config\Exception\FileLoaderLoadException]
Cannot load resource "@UserBundle/Controller/". Make sure the "UserBundle" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path "@UserBundle/Control ler/" is not empty.

I think I have right AppKernel and routing.yml: AppKernel:

<?php

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 Nelmio\ApiDocBundle\NelmioApiDocBundle(),
            new HomeBundle\HomeBundle(),
            new UserBundle\UserBundle(),
        ];

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

        return $bundles;
    }

    public function getRootDir()
    {
        return __DIR__;
    }

    public function getCacheDir()
    {
        return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
    }

    public function getLogDir()
    {
        return dirname(__DIR__).'/var/logs';
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }
}

Routing.yml:

user:
    resource: "@UserBundle/Controller"
    type:     annotation
    prefix:   /user

home:
    resource: "@HomeBundle/Controller"
    type:     annotation
    prefix:   /

NelmioApiDocBundle:
    resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
    prefix:   /api/doc

I think that problem is giving me a index of in my website.

1
Take care when writing yml syntax. That user: from routing.yml should be at the same level as home: and NelmioApiDocBundle:.Dan Costinel
sorry when I copied and pasted I did bad in my yml file is good. @DanCostinelSermanes
Post your directories structure for UserBundle.Dan Costinel

1 Answers

0
votes

I found the error, was the SensioFrameworkExtraBundle was bad declared:

  <?php

    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 Nelmio\ApiDocBundle\NelmioApiDocBundle(),
                //this bundle must be here
                new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(); 
                new HomeBundle\HomeBundle(),
                new UserBundle\UserBundle(),
            ];

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

            return $bundles;
        }

        public function getRootDir()
        {
            return __DIR__;
        }

        public function getCacheDir()
        {
            return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
        }

        public function getLogDir()
        {
            return dirname(__DIR__).'/var/logs';
        }

        public function registerContainerConfiguration(LoaderInterface $loader)
        {
            $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
        }
    }