What is the use of composer.json and in file i need to know about the script, autoloading?

Comments (2)

Ehsan Fazeli's photo

Composer is a package manager and using it, you can easily find the package you want, download and use it in your project. Composer.json, on the other hand, has all the information composer needs to build your application from scratch. In this file, you specify what package and which version you need in order to make your app work.

The autoload part of composer.json file is for "PSR-4" autoloading. It binds some directories to a first-level namespace so according to the files and directories inside the parent directory, namespaces form correspondingly.

For example, this code would make a file within path app/Foo/Bar/Baz.php having this namespace: App\Foo\Bar\Baz

"autoload": {
    "psr-4": {
        "App\\": "app/"
    }
}
Mohanraj's photo

I understand. Thank you for your response Ehsan Fazeli