Symfony generated Bundle doesn't work

南楼画角 提交于 2019-12-13 08:35:49

问题


I just created a new project with symfony 3.4 and i generated a bundle, the message from the bundle generation said it's all good, then i just start to work just by running clear cache command it display this error message

php.exe C:\wamp64\www\bunead\bin\console cache:clear Fatal error: Class 'AnnuaireBundle\AnnuaireBundle' not found in C:\wamp64\www\bunead\app\AppKernel.php on line 19

here's my Appkernel.php

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 Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new AppBundle\AppBundle(),
            new AnnuaireBundle\AnnuaireBundle(),
        ];

回答1:


You need to add It inside your composer

Try to change your composer.json to this for example:

"autoload": {
        "psr-4": {
            "": "src/"
        }
    }

After inside your console launch this:

composer dump-autoload



回答2:


The problem is the autoload of symfony.

Open you composer.json file and edit :

AnnuaireBundle\AnnuaireBundle

"autoload": {
    "psr-4": {
        "AppBundle\\": "src/AppBundle",
        "AnnuaireBundle\\": "src/AnnuaireBundle"
    },
    "classmap": [
        "app/AppKernel.php",
        "app/AppCache.php"
    ]
},

then, run the next command in your composer:

composer dumpautoload



来源:https://stackoverflow.com/questions/45017856/symfony-generated-bundle-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!