Why can't Heroku find my autoload.php file? Why can't Heroku find my autoload.php file? heroku heroku

Why can't Heroku find my autoload.php file?


I can't say for sure why this worked but it appears that Heroku doesn't really play nicely with composer.json somewhere other than the project root. So I took my project's composer.json and moved it to the project root, then I added...

"config": {    "vendor-dir": "wp-content/plugins/wp-github-pipeline/vendor"}

...which caused the dependancies I needed (and the autoload.php) to get installed in the original location.

With this, I am able to push to Heroku normally without issues.

I have NO idea why I was able to run composer install manually without it working. I also have NO idea why heroku run bash would show me files that aren't actually there.


According to me you have to regenerate the autoload. Hope that you have written code within composer.json for autoloads.

composer dump-autoload

This will regenerate your autoload and it will solve your problem. If not please modify your question by pasting your composer.json.


What I did to solve this was add an include_path to my .user.ini file. That ini file needs to be located in the document root, not the app's root.

include_path = ".:/app/.heroku/php/lib/php:/app/vendor/"

Don't copy my include_path example verbatim, as it might now be the needed include path for your app. Get your current include path from Heroku's error log, and then append :/app/vendor to it.

What's important there is adding /app/vendor/ to the include_path. That will point yourrequire php statement to the spot where Heroku puts the autoload.php.