简体   繁体   中英

Composer + Laravel 4.2 - Unable to generate PSR-0 autoloader

What i'm trying to do : setup PSR-0 autoloading but composer is generating a PSR-4 autoloader file.

I'm Using:

1) Laravel 4.2

2) Composer version e77435cd0c984e2031d915a6b42648e7b284dd5c 2014-07-02 15:44:54

My composer.json:

    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php",
            "app/libraries"
        ],
        "files": [
        "app/libraries/custom_helpers.php"
        ],
        "psr-0":{
            "MyApp":"app/"
        }
    }

//rest of the file is omitted

After this if i run composer dump-autoload in the terminal it should generate a file in the

vendor/composer directory called autoload_psr0.php

Instead it generates a autolooad_psr4.php and it looks like this :

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
);

From the composer docs i understand that psr-0 is still supported.

Could this be due to to the Monolog package requiring PSR-4 namespacing ?

Well it seems laravel actually doesn't create a separate config for the psr0 standards. It in fact has a autoload_real.php file by default which references a ClassLoader class and checks for psr-0. These files can be found in the vendor/composer directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM