Symfony3 ClassNotFoundException after bundle creation

Viewed 18660

I wanted to start a new 3.3 project in Symfony and started as usual:

1.) Creating the new project: symfony new ArtProject

2.) Creating a new Bundle: php app/console generate:bundle (Paul/ArtBundle, yml, src/)

Then I run the local server and when I open 127.0.0.1:8000 I get this beautiful message:

(1/1) ClassNotFoundException

Attempted to load class "PaulArtBundle" from namespace "Paul\ArtBundle". Did you forget a "use" statement for another namespace? in AppKernel.php (line 19)

Which is strange and I haven't figured out why this happen so far. Before creating the Bundle, there was no error; I saw the typical startpage of symfony.

public function registerBundles()
{
    $bundles = [
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        ......
        new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
        new AppBundle\AppBundle(),
        new Paul\ArtBundle\PaulArtBundle(),
    ];
}

<?php

namespace Paul\ArtBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class PaulArtBundle extends Bundle
{
}

Any idea whats going on there? I did not change a thing, I only ran these commands.

4 Answers

This works for me in:

Generate your Bundle with

./console generate:bundle

And follow the steps as always, now, do what you want in your composer.json file with the line

"AppBundle\\": "src/AppBundle"

Replace with "": "src/" or add your bundle, for example: "BackendBundle\\": "src/BackendBundle"

Here's the new part:

  1. Install composer in your bin directory, copy and paste the steps from https://getcomposer.org/download/

  2. Up a level in your project directory, and in your root folder (of your project) run the next command

php ./bin/composer.phar update

Removing vendor dir and again running composer install helped me with same problem.

Related