Why can't Heroku find the autoload.php file?
I am creating a demo site for a Wordpress plugin on Heroku. My plugin uses a linker to manage dependencies and is configured as a git submodule for my local installation. I push the hero and everything seems to work. I am using heroku run bash
ssh in an application and manually run composer install
from inside my plugin. Then I go to the site and try to activate my plugin ... but I get the following error:
Plugin could not be activated because it triggered a fatal error.
Warning: require_once(/app/wp-content/plugins/wp-github-pipeline/vendor/autoload.php): failed to open stream: No such file or directory in /app/wp-content/plugins/wp-github-pipeline/wp-github-pipeline.php on line 23 Fatal error: require_once(): Failed opening required '/app/wp-content/plugins/wp-github-pipeline/vendor/autoload.php' (include_path='.:/app/.heroku/php/lib/php') in /app/wp-content/plugins/wp-github-pipeline/wp-github-pipeline.php on line 23
I do not understand. With heroku run bash
I can see that the file is actually there. And I am not getting this problem locally or on another remote server. Why is this happening here?
source to share
I can't say exactly why it worked, but it looks like Heroku doesn't play very well with composer.json anywhere other than the project root. So I took the projecter.json project and moved it to the root of the project, then added ...
"config": {
"vendor-dir": "wp-content/plugins/wp-github-pipeline/vendor"
}
... which called the dependencies I needed (and autoload.php) to install to their original location.
This way I can push to Heroku without any problem.
I have no idea why I was able to start composer install
manually without working. I also have no idea why it heroku run bash
will show me files that are not actually there.
source to share
What I did to solve this add include_path
to my .user.ini
file. This ini file must be in the root directoryrather than at the root of the application.
include_path = ".: / app / .heroku / php / lib / php: / app / vendor /"
Do not copy my include_path
verbatim example as this may now be a necessary path to include your application. Get the current include path from Heroku error log and then add :/app/vendor
to it.
What's important to add /app/vendor/
to include_path. This will point your require
php statement to where Heroku puts autoload.php
.
source to share