简体   繁体   中英

How to deploy a php application on Google App Engine without them running composer?

As you can see here: Specifying Dependencies

Google App Engine "Composer runs automatically when you deploy a new version of your application..."

I would prefer it didn't. I have scripts that run prior to deployment to remove all of the unnecessities in composer dependencies that are not needed in a deployed application (documentation, testing, etc.).

My .gcloudignore file does not include the /vendor directory and this is confirmed by the file count on upload. When I checked the deployed source however, the composer dependencies do not match my cleaned local dependencies because App Engine is overriding them.

Not sure why this is a feature in the first place, it seems it would be better to leave this in the control of the developers.

I do have billing enabled and am full featured. Thanks!


EDIT

I added the composer.json and composer.lock files to the ignore file to prevent the update and then the vender directory was missing completely from the deployed source. The vendor directory is not in the ignored file and has been uploaded. If I add a depenency, for example, the upload file count reflects the file count for the added dependency files.

It makes me wonder if something is running after the upload during the deployment to remove the vendor directory. They do have it as being removed by default in the ignore file. I assumed though that by taking it out it would allow the upload and deployment of it (the vendor directory)

I've been working on reproducing your issue and trying to attain exactly everything you described as things you need to happen. And I've found some interesting things.

I wanted to see the exact behavior of a vendor/ folder when you deploy it to GAE and understand exactly what causes your issues, so i followed these steps:

  1. Cloned a simple PHP project just to save time.
  2. Installed composer locally so i can require the dependencies.
  3. I required a simple dependency (so it creates the vendor/, composer.json, composer.lock

    composer require phpunit/php-timer

This made me have locally the dependencies so it directly uploads them. Can you try to do that with your composer file before attempting to deploy?

  1. I did gcloud app deploy and it uploaded everything, I still have my doubts as if this is my local folder or generated at run-time.
  2. Then I made a simple .gcloudignore as a test, added test* into it, did a gcloud app deploy, and it uploaded everything except the test folders.

Here you can specify everything that you want to avoid uploading, i think this would be a much easier solution for all your troubles. These are the .gcloudignore formats you can use.

It worked for me like this, hope it can help you out.

Let me know.

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