Symfony2 - Fatal Link Bug

I have an error [Solution at the end of the question]

Fatal error: Class 'symblog\Blogger\BlogBundle\SymblogBundle' not found in /var/www/Symfony/app/AppKernel.php on line 20 

I founded the question How to install or integrate packages in Symfony2 , but the solutions you provided did not help me, because I already did what was suggested there. I follow the tutorial symblog.co.uk , except what I created in

 app/config/routing.yml 

but

 *.php resource 

Thanks in advance!

I need to add that when registering a pool on the console, I have an error

 The command was not able to configure everything automatically. You must do the following changes manually. 

And instructions:

 - Edit the app/autoload.php file and register the bundle namespace at the top of the registerNamespaces() call: 'symblog\Blogger\BlogBundle' => '/var/www/Symfony/blog', 

which I followed.

AppKernel.php

 class AppKernel extends Kernel { public function registerBundles() { $bundles = array( //.. new symblog\Blogger\BlogBundle\SymblogBundle(), ); 

/app/config/routing.yml

 SymblogBundle: resource: "@SymblogBundle/Resources/config/routing.php" prefix: / 

As requested: /app/config/config.yml

 imports: - { resource: parameters.ini } - { resource: security.yml } framework: #esi: ~ #translator: { fallback: %locale% } secret: %secret% charset: UTF-8 router: { resource: "%kernel.root_dir%/config/routing.yml" } form: true csrf_protection: true validation: { enable_annotations: true } templating: { engines: ['twig'] } #assets_version: SomeVersionScheme session: default_locale: %locale% auto_start: true # Twig Configuration twig: debug: %kernel.debug% strict_variables: %kernel.debug% # Assetic Configuration assetic: debug: %kernel.debug% use_controller: false # java: /usr/bin/java filters: cssrewrite: ~ # closure: # jar: %kernel.root_dir%/java/compiler.jar # yui_css: # jar: %kernel.root_dir%/java/yuicompressor-2.4.2.jar # Doctrine Configuration doctrine: dbal: driver: %database_driver% host: %database_host% port: %database_port% dbname: %database_name% user: %database_user% password: %database_password% charset: UTF8 orm: auto_generate_proxy_classes: %kernel.debug% auto_mapping: true # Swiftmailer Configuration swiftmailer: transport: %mailer_transport% host: %mailer_host% username: %mailer_user% password: %mailer_password% jms_security_extra: secure_controllers: true secure_all_services: false 

[Edit] The solution was very easy after the reply from @Clamidity that the packages are usually located in src / Blogger / SymBlogBundle / BloggerSymBlogBundle.php

While the configuration using the console relied on the package location, and the default was /../src, but I changed it to /../blog. And of course, this will not work, Symfony was looking for the wrong location. I did to move the folders inside / blog to / src, and everything went fine.

+7
source share
2 answers

There are a few things that could be. I will just talk about something that I can think of.

  • Usually bundles are placed in the src folder. So the path to your set should look like this.

     src/Blogger/SymBlogBundle/BloggerSymBlogBundle.php 

    (Note that the package name follows the file name convention)

  • Inside BloggerSymBlogBundle.php, make sure you have something similar to the following:

     <?php namespace Blogger\SymBlogBundle; use Symfony\Component\HttpKernel\Bundle\Bundle; class BloggerSymBlogBundle extends Bundle { } 

    (Please note that the same convention is also respected here)

  • In your autoload.php, the namespace that needs to be registered is part of the "Blogger" name / path to your set. This is due to the fact that the package itself is located in the Blogger folder:

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

    (Note that the specified folder is the parent of the Blogger folder)

  • Now in AppKernel.php register the package according to the created and registered namespace:

     new Blogger\SymBlogBundle\BloggerSymBlogBundle(), 

    * Note. Your resources and links to this kit with the specified configuration will be

     BloggerSymBlogBundle 

    so that your php routing is invoked with:

     @BloggerSymBlogBundle/Resources/config/routing.php 
+13
source

There are different solutions.

Empty the app / cache / (prod | dev) folder. When you edited Appkernel and Startup.

Fatal error: class 'symblog \ Blogger \ BlogBundle \ SymblogBundle' was not found in /var/www/Symfony/app/AppKernel.php on line 20

Now there are different problems:

  • Look at the SymblogBundle.php in the Bundle folder and see what namespace they use. Perhaps this is indeed an uppercase letter ("S"), similar to @kuba.

  • The class file is not in the folder or you do not have rights to the folder that the interpreter can load the file.

  • I think your autoload.php is incorrect.

     'Avalanche' => __DIR__.'/../vendor/bundles', 

    This is the usual way to register a namespace. In your case, it should be

     'Symlog' => '/var/www/Symfony/blog', 

Here are the instructions from the "BloggerBundle". I hope it is correct.

There you can see that your startup is not correct and the namespace is "Blogger".

+4
source

All Articles