nov*_*ung 4 php heroku composer-php
我正在尝试将 PHP 项目部署到 Heroku。我使用 Composer 来安装slim framework和simple_http_dom依赖项。这是我的内容composer.json:
{
"require": {
"slim/slim": "2.4.3",
"shark/simple_html_dom": "dev-master"
}
}
Run Code Online (Sandbox Code Playgroud)
当我在本地运行该应用程序时,它工作正常。然后我尝试将其推送到Heroku,似乎成功了,我没有看到任何错误消息。
但是,当我尝试从浏览器访问它时出现问题。什么也没有出现。以下是命令的日志heroku logs。
[Sun Aug 31 00:14:37.566291 2014] [proxy_fcgi:error] [pid 60:tid 140467698300672] [client 10.2.162.208:58783] AH01071: Got error 'PHP message: PHP Fatal error: Call to undefined function mb_detect_encoding() in /app/vendor/shark/simple_html_dom/simple_html_dom.php on line 1234\n', referer: http://myapp.herokuapp.com/index.php/scrap/all
[31/Aug/2014:00:14:37 +0000] "POST /index.php/scrap/all/do HTTP/1.1" 500 - "http://myapp.herokuapp.com/index.php/scrap/all" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36"
[31-Aug-2014 00:14:37] WARNING: [pool www] child 58 said into stderr: "NOTICE: PHP message: PHP Fatal error: Call to undefined function mb_detect_encoding() in /app/vendor/shark/simple_html_dom/simple_html_dom.php on line 1234"
Run Code Online (Sandbox Code Playgroud)
错误中的一段可能很有趣:
Got error 'PHP message: PHP Fatal error: Call to undefined function mb_detect_encoding() in /app/vendor/shark/simple_html_dom/simple_html_dom.php on line 1234\n', referer: http://myapp.herokuapp.com/index.php/scrap/all
Run Code Online (Sandbox Code Playgroud)
这是我第一次遇到上述错误。我有另一个应用程序在 Heroku 上运行,使用相同的依赖项(但没有 Composer)并且它工作正常,但这个不是。
我应该怎么做才能解决这个问题?
问题是mbstring默认情况下未启用该扩展,请参阅https://devcenter.heroku.com/articles/php-support#extensions
只需添加ext-mbstring为依赖项即可,composer.json如下所示:
{
"require": {
"ext-mbstring": "*",
"slim/slim": "2.4.3",
"shark/simple_html_dom": "dev-master"
}
}
Run Code Online (Sandbox Code Playgroud)
当您执行以下操作时,Heroku 将自动启用该扩展git push。
| 归档时间: |
|
| 查看次数: |
3095 次 |
| 最近记录: |