symfonyL Unable to find file "@AppBundle/Resources/config/routing.yml"

I’m still learning symfony and I ran into a problem i can’t seem to figure out whats causing the problem.
Symfony vs 2.7
newly created bundle

the routing did work before i changed the location to resource: “@AppBundle/Resources/config/routing.yml” so im assuming the bundle is registered. Either case I used a online tutorial but its not working in my case.

error message:
Unable to find file “@AppBundle/Resources/config/routing.yml” in @AppBundle/Resources/config/routing.yml (which is being imported from “/home/rob/webhtdocs/symfony/project2/app/config/routing.yml”). Make sure the “AppBundle” bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path “@AppBundle/Resources/config/routing.yml” is not empty.

file located at: app/config/routing.yml

app:
    resource: "@AppBundle/Resources/config/routing.yml"

file located at: src/AppBundle/Resources/config/routing.yml

demo_homepage:
    path: /hello
    defaults: { _controller: AppBundle:Default:index }

AppKernal.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            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 Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new AppBundle\AppBundle(),
        );

        if (in_array($this->getEnvironment(), array('dev', 'test'))) {
            $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 registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }
}

also see screenshot**
**

Your setup seems right. Try clearing the cache.

app/console cache:clear

Hi ahundiak,

Thanks for the reply back…
I ran the the command to clear the cache but it brings up a different error message:

RuntimeException in ClassCollectionLoader.php line 239:
Failed to write cache file "/home/rob/webhtdocs/symfony/project2/app/cache/dev/classes.php".

To resolve the runtimeexception message i run this command -->: sudo rm -rf app/cache/*

but it doesnt resolve the original problem, I’m back to getting the original messsage, routing not found message.

At a glance, I can’t spot anything wrong either. Could you post your project on github or something like that so we can reproduce the issue?

Hi Jeff_mott,

thanks for the reply back.
I am aware of Github site but not all the familiar as to how to use the github so im going to just delete/recreate the bundle and hope for the best that it works other wise ill be back…

for a php framework that supposed to make things easy it doesn’t make it easy to create and run a new bundle with out a lot running round… lol

app/console generate:bundle

You did not specify which tutorial you are trying to follow. You might consider working you way through the official documentation:

And do take the time to learn git and github. Writing code with a source control system is like riding a bicycle without a seat.

Unless you’re pretty familiar with modern design patterns and middleware technologies frameworks are a steep learning curve. Everyone says their sh*t is easy to learn – It never is. Putting that aside Symfony is most definitely one of the top notch PHP frameworks out there. Not to mention Symfony knowledge indirectly translates at least partially to many other projects which make use of the Symfony ecosystem/components. Also Symfony will hand hold you through learning many of the middleware level technologies that just about all php projects are using these days like git (version control) and composer (dependency management). Furthermore, many third party libs are also used like Monolog (logging) and Swiftmailer (mailer) which are used in MANY other projects since they are essentially independent – stand-alone libraries – which can be used in any php context.

1 Like

You did mean

Writing code without a source control system is like riding a bicycle without a seat.

didn’t you?

Scott

You also need to make sure the /app/cache directory is writable by whichever user your system is calling the PHP files with.

And Symfony is a pretty powerful framework. If things go wrong though, and you don’t know where to look or have no idea what is breaking and why, then it is like looking at Mount Everest for the first time and thinking now you’ll have to climb it, even though you really don’t want to. That is the downside of such frameworks. They are magical, when everything works right, and downright massively complex and mysterious, when things go wrong.

Scott

1 Like

Either case it sounds like a painful experience :smile:

To be fair that is the typical experience with anyone else’s code. At least with large community backed projects there is *normally documentation and community support. Unless you’re building something in complete isolation chances are the next person to inherit your code which uses open source technology will hate you much less than had you not.

1 Like

Hello everybody,

Thanks for all of your replies.

After having spent a week trying to figure out the causing of the problem; at the end it was the permission setting on the folder(s).

If I’m not mistaken someone did mention permission setting but based on the error message I didn’t think it had anything to do with permission.

The original bundle I created with the help of an online tutorial, didn’t really set any permissions on the folder or folders in question but yet it worked but not so on the second bundle.

So I decided to compare the permission settings with 2 separate ftp sessions and sure enough it was the permission settings on the folder prevented the proper execution application.

My fault, live and learn I guess.

Hihi. I told you so. :blush:

It is a permissions problem because, as the PHP user, Symfony at request time tries to build the cache, if the cache directory is empty or outdated. If the folders are built with the wrong permissions or for a user/group that isn’t the PHP user, Symfony balks with the failed to write cache error.

Scott

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.