Why my autoload.php of composer doesn't work?

Try using php composer dump-autoload. It may fix that problem.


If you are using a file (file.php) in a particular directory like this:

/app/controller/validation

and your vendor directory is in the base path of the project, you need to include the relative path to vendor directory:

../../../vendor/autoload.php

I did this. i checked the file and permissions as always but everything looks ok. Then I open autoload.php and see ... oh! we have __DIR__ ofcourse.

I was doing this

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

Changed to

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

Not politically correct but got me by the frustrating waste of time for the moment.

ofcourse there are better alternatives to __DIR__ like using a BASE Path etc. But this worked for me.