30

Heroku said:

The following built-in extensions have been built “shared” and can be enabled through composer.json (internal identifier names given in parentheses):

But it doesn't give an example, I tried with the following composer.json: { "require": { "gd": "*" } }

But when I git push heroku master, I get:

My composer.json: { "require": { "gd": "*" } }

But when I git push heroku master, I get:

-----> Installing dependencies...
       Composer version 1.0.0-alpha9-19-g10401d5 2014-12-09 11:32:02
       Loading composer repositories with package information
       Installing dependencies
       Your requirements could not be resolved to an installable set of packages.

         Problem 1
           - The requested package gd could not be found in any version, there may be a typo     in the package name.

       Potential causes:
        - A typo in the package name
        - The package is not available in a stable-enough version according to your minimum-    stability setting
          see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

       Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

 !     Push rejected, failed to compile PHP app

How can I enable gd on heroku???

Jeff Tian
  • 5,210
  • 3
  • 51
  • 71

2 Answers2

68

Try it with:

{
    "require": {
        "ext-gd": "*"
    }
}

see here using-optional-extensions

monofone
  • 860
  • 8
  • 16
  • 1
    Note, this solution should be contained in a .json text file in the root directory of your project (same directory as your .git folder). Commit and push these changes and they should take affect. – ecoe May 25 '15 at 21:04
  • 1
    `Problem 1 - The requested PHP extension ext-gd * is missing from your system. Install or enable PHP's gd extension.` and I can't install it from sudo as `sudo apt-get install php5.6-gd` says `sudo: command not found` – Dario Rusignuolo Oct 19 '16 at 18:59
  • Thank you! Saved me from a massive headache! +1 – Chris Kempen May 19 '17 at 11:52
  • 2
    After this modification, you need to run `composer update` so your changes are reflected in composer.lock – Sebj Nov 18 '20 at 18:25
4

Just adding GD as dependency (require) in composer does not load the extension GD. It just tells that this package needs gd enabled. "ext-gd" is just a virtual package, not existing for real.

you have to install it on your platform.

see here composer - platform-packages

IMM0rtalis
  • 61
  • 7
  • 1
    For those who are confused: ensure you have installed php*.*-gd (see http://stackoverflow.com/q/2283199/4900327), then run `composer update` in your repo directory, and optionally add `vendor/*` to your .gitignore – Abhishek Divekar Feb 16 '17 at 19:28
  • @abhidivekar how do you run apt-get on heroku? when I try apt-get in `heroku run bash` shell I get read-only errors preventing me from installing. php info says compiled `--with-gd=shared` though, it's confusing. – danronmoon Jul 16 '17 at 03:50
  • Found out it had to do with getting it installed locally. – danronmoon Jul 16 '17 at 04:35
  • well explained. This should be the correct answer. Thanks – Alauddin Ahmed Apr 07 '19 at 14:54