我尝试在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": "my@email.it"
}
],
"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
答案 0 :(得分:1)
这不是Heroku的问题,而是本地计算机的问题。
您在本地运行composer update
以重新生成composer.lock
。您的composer.json
包含ext-gd
的要求,因此您的本地计算机的PHP安装必须启用该扩展程序,否则无法满足要求,并且Composer会对此提出错误。
https://devcenter.heroku.com/articles/php-support#using-optional-extensions解释了确切的情况以及解决问题的方法 - 请仔细按照其中的说明进行操作,包括蓝框中的注释,指示您根据需要运行composer update --ignore-platform-reqs
。
答案 1 :(得分:0)
gd在Heroku上可用,您必须通过将以下行添加到composer.json(在require部分下)来启用它。
"ext-gd": "*"
确保在将代码推送到heroku之前在本地运行composer update
,否则它将无效。
答案 2 :(得分:0)
首先,您必须在本地捆绑php。
1。步骤 包含在您的composer.json
中{
"require": {
..
"ext-gd": "*",
...
}
}
2。步骤 更新作曲家
composer update
要花时间。...喝咖啡。
3。步骤 用heroku cli发布
git push heroku master
关于pusblish,请注意输出,并检查下面是否有类似我的第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...
快乐的编码。
答案 3 :(得分:-1)
在本地解决问题composer install
,然后通过git存储库部署到heroku应用程序。