Composer and Autoloading


To add your own code to the autoloader by adding an autoload field to

"autoload": {
"psr-4": {"Acme\\": "src/"}

Update Composer from terminal:

composer update

This will generate a vendor directory containing dependencies.

Hope your application entry point is index.php.

So, import autoload.php file from vendor directory.

require __DIR__ . '/vendor/autoload.php';

Dump autoloading using composer.

composer dump-autoload

Above command will just regenerates the list of all classes that need to be included in the project (autoload_classmap.php).


Software Engineer at The Jaxara IT Ltd , Dhaka , Bangladesh

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: