PHP Heroku - call undefined function mb_detect_encoding ()
I am trying to deploy some php project to hero. I am using composer with required dependency slim framework
and simple_http_dom
. Here's the content of mine composer.json
:
{
"require": {
"slim/slim": "2.4.3",
"shark/simple_html_dom": "dev-master"
}
}
when i run this app locally it works like a charm.
My app has been successfully ported to hero. the problem occured when i try to access it from the browser. it doesn't show anything. here are some hints for the error i got from the team heroku logs
.
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\n', 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"
he 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\n', referer: http://myapp.herokuapp.com/index.php/scrap/all
This is the first time I got this error. I have another project running per hero using the same dependencies (but without composer) and it works smoothly.
what should i do to fix this problem?
source to share
The problem is that the extension mbstring
is not enabled by default, see https://devcenter.heroku.com/articles/php-support#extensions
Just add ext-mbstring
as a dependency of yours composer.json
so it looks like this:
{
"require": {
"ext-mbstring": "*",
"slim/slim": "2.4.3",
"shark/simple_html_dom": "dev-master"
}
}
Heroku will then automatically activate the extension if you git push
.
source to share