0
votes

Looking at composer.json file in laravel project, I can find below

    "autoload": {
    "psr-4": {
        "App\\": "app/"
    },
    "classmap": [
        "database/seeds",
        "database/factories"
    ]
},

as far as I know App\:"app/" means a name space starts with App has its source files under the app/ directory and it follows psr-4.

however, there are ton's of packages under the vendor directory for instance packages start with Illuminate.. Are they under psr-4 or classmap? why are they not declared in the composer.json file?

1

1 Answers

1
votes

Every package should be responsible for autoloading itself

Consider Laravel as a single package like others

You can find vendor composer.json files in each packages separately

Here are the directory structure

<web-root>
    |--------src/
    |           |--------App/
    |           |
    |           |--------Test/
    |
    |---------library/
    |
    |---------vendor/
    |           |
    |           |---------composer/
    |           |           |---------autoload_psr4.php
    |           |           
    |           |----------autoload.php
    |
    |-----------composer.json
    |

You can take a look my another answer for this autoload classmap