Error creating bundle in symfony 4

0

Good I have this error when running php bin / console, it throws me the following:

  

In FileLoader.php line 168:                                                                                                        The autoloader expected class   "App \ TestBundle \ Controller \ DefaultController" to be defined in
  file   "/opt/lampp/htdocs/symfony/my-project/vendor/composer/../../src/PruebaBundle/Controller/   DefaultController.php ".The file was found but the class was not in   it, the class name or name space probably has a typo in   /opt/lampp/htdocs/symfony/my-project/config/services.yaml (which
  is loaded in resource   "/opt/lampp/htdocs/symfony/my-project/config/services.yaml").

     

In DebugClassLoader.php line 293:                                                                                                        The autoloader expected class   "App \ TestBundle \ Controller \ DefaultController" to be defined in
  file   "/opt/lampp/htdocs/symfony/my-project/vendor/composer/../../src/PruebaBundle/Controller/   DefaultController.php ".The file was found but the class was not in   it, the class name or name space probably has a typo. }

Here my composer.json

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.0.8",
        "ext-iconv": "*",
        "sensio/framework-extra-bundle": "^5.1",
        "sensio/generator-bundle": "3.0",
        "symfony/asset": "^3.4",
        "symfony/console": "^3.4",
        "symfony/expression-language": "^3.4",
        "symfony/flex": "^1.0",
        "symfony/form": "^3.4",
        "symfony/framework-bundle": "^3.4",
        "symfony/lts": "^3",
        "symfony/monolog-bundle": "^3.1",
        "symfony/orm-pack": "*",
        "symfony/process": "^3.4",
        "symfony/security-bundle": "^3.4",
        "symfony/serializer-pack": "*",
        "symfony/swiftmailer-bundle": "^3.1",
        "symfony/twig-bundle": "^3.4",
        "symfony/validator": "^3.4",
        "symfony/web-link": "^3.4",
        "symfony/webpack-encore-pack": "*",
        "symfony/yaml": "^3.4"
    },
    "require-dev": {
        "symfony/browser-kit": "^3.4",
        "symfony/css-selector": "^3.4",
        "symfony/debug-pack": "*",
        "symfony/dotenv": "^3.4",
        "symfony/maker-bundle": "^1.0",
        "symfony/phpunit-bridge": "^3.4",
        "symfony/profiler-pack": "*",
        "symfony/web-server-bundle": "^3.4"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\Tests\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "id": "01CA1B4DDM0ZQNNSBKAHV3RET0",
            "allow-contrib": false
        }
    }
}
    
asked by Enrique Milano 04.04.2018 в 17:11
source

2 answers

1

Try modifying this:

"autoload": {
        "psr-4": {
            "": "src/"
        }
    },
    
answered by 12.04.2018 в 17:35
0

Symfony 4 recommends not using bundles to organize the code (It is one of the most important changes in this version)

  

In Symfony versions prior to 4.0, it was recommended to organize your   own application code using bundles. This is no longer recommended and   bundles should only be used to share code and features between   multiple applications.

link

link

Slds

    
answered by 27.05.2018 в 19:26