13

I'm trying to run a symfony4 application in the Google Cloud App Engine following this instructions.

My app has a dependency which itself depends on php-gd. This extension seems to be unavailable since composer fails with the requested PHP extension gd is missing from your system..

How would I have to modify the tutorial to have the extension available?

Can this be solved with a php.ini file or do I need a custom environment?

Alternatively since I don't need the parts of my dependency which require php-gd, is there a way to get composer run with the --ignore-platform-reqs flag?

Johannes Buchholz
  • 1,857
  • 19
  • 34

3 Answers3

3

Make sure to get installed this php-gd or apt-get install php5-gd

-your OS apt-get install php gd or apt-get install php5-gd, be aware of your php version.

The other approach here woulbe to add "ext-gd": "*" to your application's composer.json:

composer require "ext-gd:*" --ignore-platform-reqs It doesn't matter if gd is enabled in your local PHP install, the flexible environment is built using your composer.json and app.yaml files, so you need to add it there.

Jose Antonio
  • 840
  • 14
  • 25
  • I'm not working with a local installation. I am using the Google Cloud App engine where I can't just install an extension, which is exactly my problem. The question is about how to get the extension installed (or ignored by composer) in this environment. – Johannes Buchholz Sep 18 '18 at 07:40
  • I believe this can be solved through php.ini at the root of the application (https://cloud.google.com/appengine/docs/flexible/php/runtime#using_php_extensions), but not through composer.json since it doesn't allow extension management through it. – Daniel Protopopov Sep 18 '18 at 10:47
  • 3
    @DanielProtopopov "but not through composer.json..." that is not entirely true. The documentation you linked to states "Alternatively, you can also enable an extension by adding a require to your composer.json". Composer itself does not manage extensions but if Google Cloud App Engine parses the composer.json to enable extensions it effectively does that there. – VaaChar Sep 20 '18 at 14:37
  • @VaaChar Yup, you’re right, skipped over that fact briefly not looking in – Daniel Protopopov Sep 20 '18 at 18:15
  • @VarChar please rewrite your comment as an answer, for me to accept it. – Johannes Buchholz Sep 22 '18 at 18:20
3

Well this is based on Symfony

So on the root of your application create a file php.ini

In the file enter this line

extension=gd.so

So that your php.ini file will look like this.

sample

Mwangi Thiga
  • 1,339
  • 18
  • 22
1

Google Cloud App Engine only seems to load extensions required in the top level composer.json's require.

It does not seem to resolve dependencies recursevly.

Therefore a workaroud is to add all required extensions manually to the projects composer.json.

Johannes Buchholz
  • 1,857
  • 19
  • 34