skip to Main Content

I’m trying to install gd (or ext-gd) libraries on heroku.

When I try to install them using composer (I have it as follows)

{
    "name": "cool/app",
    "type": "project",
    "require": {
        "ext-gd": "dev-master" (tried also installing "gd":"*", "ext-gd" : "*")
    },
    "license": "2016",
    "authors": [
        {
            "name": "Dario",
            "email": "[email protected]"
        }
    ],
    "minimum-stability": "dev"
}

I got

Problem 1
- The requested PHP extension ext-gd * is missing from your system. Install or enable PHP's gd extension.

So, tried to install from apt-get (sudo apt-get install php7-gd), but I dont have sudo permissions as I don’t know the root heroku password.

Any work around on this?

EDIT

To explain better what I’ve done, here’s the entire commands list

$ heroku run bash
Running bash on ⬢ app... up, run.1644 (Free)
~ $ composer init


  Welcome to the Composer config generator  



This command will guide you through creating your composer.json config.

Package name (<vendor>/<name>) [app/app]: 
Description []: 
Author [, n to skip]: n
Minimum Stability []: 
Package Type (e.g. library, project, metapackage, composer-plugin) []: 
License []: 

Define your dependencies.

Would you like to define your dependencies (require) interactively [yes]? 
Search for a package: ext-gd

Found 15 packages matching ext-gd

   [0] stil/gd-text
   [1] gd/plesk-bundle
   [2] quince/persian-gd
   [3] xepan/gd-text
   [4] zgldh/gd-text-for-chinese
   [5] ext-calendar
   [6] ext-iconv
   [7] ext-dbus
   [8] ext-xml
   [9] ext-opendkim
  [10] ext-mcrypt
  [11] ext-openssl
  [12] ext-ssh2
  [13] ext-mongo
  [14] ext-mbstring

Enter package # to add, or the complete package name if it is not listed: ext-gd
Enter the version constraint to require (or leave blank to use the latest version): *
Search for a package: 
Would you like to define your dev dependencies (require-dev) interactively [yes]? no

{
    "name": "u11706/app",
    "require": {
        "ext-gd": "*"
    }
}

Do you confirm generation [yes]? 
~ $ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-gd * is missing from your system. Install or enable PHP's gd extension.

~ $ composer update --ignore-platform-reqs
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files

And I’m unable to use the gd libraries as php (Laravel) says Call to undefined function AppHttpControllersimagecreatefrompng()

If I run composer require ext-gd from my local computer I get

Using version ^0.0.0 for ext-gd
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files

4

Answers


  1. Chosen as BEST ANSWER

    Solved the issue by composer install locally and then deploy via git repository to heroku app.


  2. This is not really a Heroku problem, but something with your local computer.

    You are running composer update locally to re-generate composer.lock. Your composer.json contains a requirement for ext-gd, so your local computer’s PHP install must have that extension enabled, otherwise the requirements can’t be satisfied and Composer throws an error about that.

    That exact situation, and ways to work around it, are explained at https://devcenter.heroku.com/articles/php-support#using-optional-extensions – please follow the instructions there carefully, including the notes in the blue box that instruct you to run composer update --ignore-platform-reqs if needed.

    Login or Signup to reply.
  3. gd is available on Heroku, you have to enable it by adding the following line to composer.json (under require section).

    "ext-gd": "*"
    

    Make sure to run composer update locally before pushing the code to heroku, or else It will not work.

    Login or Signup to reply.
  4. First off, You must bundle with php locally.

    1. Step
    Include in your composer.json

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

    2. Step
    Update composer

    composer update
    

    it takes a time….take a coffe..

    3. Step
    publish with heroku cli

    git push heroku master
    

    On pusblish pay attention to output and check if you have something like my line 5 below, if you have it all’s right.

    1. remote: -----> PHP app detected
    2. remote: -----> Bootstrapping...
    3. remote: -----> Installing platform packages...
    4. remote:        - php (7.3.6)
    5. remote:        - ext-gd (bundled with php)
    6. remote:        - apache (2.4.39)
    7. remote:        - nginx (1.16.0)
    8. remote: -----> Installing dependencies...
    

    happy coding.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search