Symfony2 - Fatal error with Bundles

前端 未结 2 2048
名媛妹妹
名媛妹妹 2021-01-18 07:37

I\'ve got the error [Solution at the end of the question]

Fatal error: Class \'symblog\\Blogger\\BlogBundle\\SymblogBundle\' not found in
/var/www/Symfony/ap         


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-01-18 08:21

    There are a few things that it could be. I'll just cover anything I can think of.

    1. Generally bundles are placed in the src folder. So the path to your bundle should look like this.

      src/Blogger/SymBlogBundle/BloggerSymBlogBundle.php
      

      (Notice that the bundle name follows the file name convention)

    2. Inside of the BloggerSymBlogBundle.php make sure you have something similar to the following:

      (Notice that the same name convention is also followed here)

    3. In your autoload.php the namespace that should be registered is the "Blogger" part of the name/path to your bundle. This is because the bundle itself resides in the Blogger folder:

      'Blogger' => __DIR__.'/../src',
      

      (Notice that the folder listed is the parent of the Blogger folder)

    4. Now in the AppKernel.php register the bundle according the namespace your set up and registered:

      new Blogger\SymBlogBundle\BloggerSymBlogBundle(),
      

      *Note - Your resources and references to this bundle with the above configuration would be

      BloggerSymBlogBundle
      

      so your php routing would be called by using:

      @BloggerSymBlogBundle/Resources/config/routing.php
      

提交回复
热议问题