Symfony 3 bundle creation always throws “Edit the composer.json file”

后端 未结 3 808
-上瘾入骨i
-上瘾入骨i 2021-02-06 12:00

Hi I\'ve been learning symfony, and every time I use the \"php bin/console generate:bundle\" command to create a bundle, even though I leave everything by default, I keep gettin

相关标签:
3条回答
  • 2021-02-06 12:24

    Edit composer.json:

    Before:

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

    After:

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

    Then run:

    composer dump-autoload 
    
    0 讨论(0)
  • 2021-02-06 12:28

    Only change composer.json:

    Before:

    "psr-4": {
                "AppBundle\\": "src/AppBundle"
            },
    

    After:

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

    And finally, run:

    composer dump-autoload
    
    0 讨论(0)
  • 2021-02-06 12:45

    I had this problem in symfony 3.4.4 too.I use this role in composer.json And then the problem was fixed

    befor

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

    after

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

    and then, cmd $ composer dump-autoload.

    0 讨论(0)
提交回复
热议问题