我正在尝试在 gd 上安装 heroku (或 ext-gd )库。

当我尝试使用 composer 安装它们时(我有如下)

{
    "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"
}

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

因此,尝试从 apt-get ( sudo apt-get install php7-gd ) 安装,但我没有 sudo 权限,因为我不知道 root heroku 密码。

有什么解决办法吗?

编辑

为了更好地解释我所做的,这里是整个命令列表
$ 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

而且我无法使用 gd 库,因为 php (Laravel) 说 Call to undefined function App\Http\Controllers\imagecreatefrompng()
如果我从本地计算机运行 composer require ext-gd 我得到
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

最佳答案

首先,您必须在本地绑定(bind) php。

1. 步骤
包含在你的 composer.json 中

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

2. 步骤
更新 Composer
composer update

这需要时间......喝杯咖啡......

3. 步骤
使用 heroku cli 发布
git push heroku master

在发布时注意输出并检查您是否有类似我下面第 5 行的内容,如果一切正常。
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...

快乐编码。

关于php - heroku 安装 gd 扩展失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40176552/

10-12 13:42