duanchi3109 2014-08-31 00:27
浏览 98
已采纳

PHP Heroku - 调用未定义的函数mb_detect_encoding()

I'm trying to deploy some php project to heroku. I use composer with required dependency are slim framework and simple_http_dom. Here content of my composer.json:

{
    "require": {
        "slim/slim": "2.4.3",
        "shark/simple_html_dom": "dev-master"
    }
}

when I run this app locally, it's working like a charm.

my app is succeed pushed to heroku. the problem occured when I try to access it from browser. it showing up nothing. here is some clue of the error i've got from heroku logs command.

2014-08-31T00:14:38.052441+00:00 app[web.1]: [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
', referer: http://myapp.herokuapp.com/index.php/scrap/all
2014-08-31T00:14:38.052437+00:00 app[web.1]: 10.2.162.208 - - [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"
2014-08-31T00:14:38.052443+00:00 app[web.1]: [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"

it said:

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 ', referer: http://myapp.herokuapp.com/index.php/scrap/all

This is the first time I got this error. I have another project run on heroku using same dependencies (but without composer) and it's smoothly working.

what should I do to fix this problem ?

  • 写回答

1条回答 默认 最新

  • doushui20090526 2014-09-02 21:15
    关注

    The problem is that the mbstring extension isn't enabled by default, see https://devcenter.heroku.com/articles/php-support#extensions

    Just add ext-mbstring as a dependency to your composer.json so it looks like this:

    {
        "require": {
            "ext-mbstring": "*",
            "slim/slim": "2.4.3",
            "shark/simple_html_dom": "dev-master"
        }
    }
    

    Heroku will then auto enable the extension when you git push.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条