简体   繁体   中英

Update composer.json for Google APP Engine

Enviroment: php 7.3

I added a new package to local composer.json

How can I move the changes? gcloud app deploy seems to ignore it as the new files doesnt appear there.

Is there anything else that needs to be run in order to check the new composer.json and update it live?

From the GCP documentation :

Composer runs automatically when you deploy a new version of your application. Simply add the following line to the top of your PHP scripts to require the autoload.php file:

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

Also,

Scripts defined in your composer.json file will not run when Composer can use a cached result.

By default, App Engine caches fetched dependencies to reduce build times. To install an uncached version of the dependency, use the command:

 gcloud beta app deploy --no-cache

Let me know if that helps!

I had this issue, and eventually realised I had to run:

composer install

before running

gcloud app deploy

I'm putting this answer here in case it helps someone else...

By trial and error I have discovered that GAE will actually load your Composer resources before your entrypoint script is called, I had Composer file autoloads specified in composer.json "autoload":{"files":[...]} and I found out that those files are actually called before my call to vendor/autoload.php in my entrypoint script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM