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
Solved the issue by
composer install
locally and then deploy via git repository to heroku app.This is not really a Heroku problem, but something with your local computer.
You are running
composer update
locally to re-generatecomposer.lock
. Yourcomposer.json
contains a requirement forext-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.gd is available on Heroku, you have to enable it by adding the following line to composer.json (under require section).
Make sure to run
composer update
locally before pushing the code to heroku, or else It will not work.First off, You must bundle with php locally.
1. Step
Include in your composer.json
2. Step
Update composer
it takes a time….take a coffe..
3. Step
publish with heroku cli
On pusblish pay attention to output and check if you have something like my line 5 below, if you have it all’s right.
happy coding.