PHP Heroku - Call undefined function mb_detect_encoding() - php

I'm trying to deploy a PHP project to Heroku. I use composer with to install slim framework and simple_http_dom dependencies. Here content of my composer.json:
{
"require": {
"slim/slim": "2.4.3",
"shark/simple_html_dom": "dev-master"
}
}
when I run the app locally, it's working fine. Then I tried to push it to Heroku, and it seems successful, I saw no error message.
However, there is a problem when I tried to access it from the browser. nothing shows up. Below is the log from heroku logs command.
[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"
One piece from the error that might be interesting:
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 the above error. I have another app running on Heroku using the same dependencies (but without composer) and it's working fine, but this one isn't.
what should I do to fix this problem?

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.

Related

PHP-fpm session_start() undefended in ptero container

I have a pterodactyl container running with a nginx and fpm egg (https://gitlab.com/tenten8401/pterodactyl-nginx) and am trying to get my sharex image uploader moved from my old site. However every time i try and access the site i get this error
2021/06/08 19:25:38 [error] 19#19: *7 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function session_start() in /home/container/webroot/index.php:4
Stack trace:
#0 {main}
thrown in /home/container/webroot/index.php on line 4" while reading response header from upstream, client: ip.address, server: , request: "GET / HTTP/1.0", upstream: "fastcgi://unix:/tmp/php-fpm.sock:", host: "ip.address:20004"
173.249.9.172 - - [08/Jun/2021:19:25:38 +0000] "GET / HTTP/1.0" 500 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ip.address Safari/537.36"
I have tried installing the package as found in this answer (Call to undefined function session_start()) but it just says opkg isnt found on the path as for the php -i once again says php isnt found on the path (both run inside the docker container). I have also tried apk add php7-mod-session but i get a permission error from the container.
I have tried a few things from adding php-mod-session to the apk add and some other stuff but nothing ever changes the error so i dont believe any of these are the right line of progress.
Any help or hints in the right direction would be great, me and my friend have been working on this for a week or so now but cant find the fix. I can also add config files and stuff if you feel they might help, just ask.

Clean wordpress instalation first load problem php7.4

I just downloaded wordpress, copied it to ISPConfig vhost, with php7.4-fpm and got this error when I want to first load WP and configure DB connection.
[proxy_fcgi:error] [pid 14720] [client 62.109.143.214:39852] AH01071:
Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to
undefined function wp_guess_url() in
/var/www/clients/client1/web31/web/wp-load.php:56\nStack trace:\n#0
/var/www/clients/client1/web31/web/wp-blog-header.php(13):
require_once()\n#1 /var/www/clients/client1/web31/web/index.php(17):
require('/var/www/client...')\n#2 {main}\n thrown in
/var/www/clients/client1/web31/web/wp-load.php on line 56'
PHP7.4-FPM is working I tested it on another site where I already have WordPress and it is working.
Seems like my linux has corrupted or bugged "Ark" (Archiving Tool) and it was not able to extract all datas.
I downloaded WordPress with wget on server and copied to webroot and it works now. Thanks #cobrerahector for tip.

"Failed to start the session: already started by PHP" error using a CMS

I installed a CMS, named Prestashop: it runs under a specific domain, and with a specific VirtualHost configuration on Apache, on a server with other PHP applications.
When I try to login in, as administrator user, I receive the following error (this is the Apache error log):
[Wed Jan 18 00:09:16.059190 2017] [:error] [pid 31253] [client xx.xx.xx.xx:63129] PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to start the session: already started by PHP.' in /opt/wp/apps/prestashop/app/cache/prod/classes.php:108\nStack trace:\n#0 /opt/wp/apps/prestashop/app/cache/prod/classes.php(483): Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start()\n#1 /opt/wp/apps/prestashop/vendor/symfony/symfony/src/Symfony/Component/Security/Csrf/TokenStorage/SessionTokenStorage.php(90): Symfony\Component\HttpFoundation\Session\Session->start()\n#2 /opt/wp/apps/prestashop/vendor/symfony/symfony/src/Symfony/Component/Security/Csrf/CsrfTokenManager.php(54): Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage->hasToken('ANONYMOUS_USER')\n#3 /opt/wp/apps/prestashop/app/cache/prod/classes.php(8196): Symfony\Component\Security\Csrf\CsrfTokenManager->getToken('ANONYMOUS_USER')\n#4 /opt/wp/apps/prestashop/classes/Link.php(722): PrestaShopBundle\Service\Routing\Router->generate('admin_product_c...')\n#5 /opt/wordpre in /opt/wp/apps/prestashop/app/bootstrap.php.cache on line 3216, referer: http://www.xxxxx.xx/adminXXX/index.php?controller=AdminLogin&token=181fa270d47386a8d523bdea6213932c&redirect=AdminDashboard'
PHP session auto_start parameter is set to 0 in php.ini.
I don't understand how can I solve this problem. It can be depends on an Apache or PHP configuration?
Thanks a lot.
I Just got the same issue with my Symfony 3.2 app, i was upgrading my web server from php 5.5.12 to php 5.6.31 when it happened. After upgrading again to php 7.0.23 everything go back to normal.

Bluemix PHP app fails on LDAP connection

This is a follow up ticket to one which was closed without answer:
https://stackoverflow.com/questions/34515574/ibm-bluemix-authentication-using-tivoli-ldap
I have migrated a PHP app which requires LDAP authentication to Bluemix and I am getting the following error:
2016-01-08T10:28:53.87+0000 [App/0] OUT 10:28:53 httpd | [Fri Jan 08 10:28:53.869250 2016] [proxy_fcgi:error] [pid 44:tid 139703240013568] [client 169.53.20.45:7120] AH01071: Got error 'PHP message: PHP Fatal error: Call to undefined function ldap_connect() in /home/vcap/app/htdocs/utils/LoginLDAP.Class.php on line 21\n', referer: http://sbrooms.w3ibm.mybluemix.net/index.php
Please note that this is not the public Bluemix, but the internal IBM one (w3ibm.mybluemix.net), hence the connection to the LDAP server should be available.
Do I have to explicitly request the connection to the LDAP server, or something else is going wrong?
Thanks,
Pimmy
Looks like the LDAP-Extension for PHP is not installed on the WebServer. The PHP message: PHP Fatal error: Call to undefined function ldap_connect() suggests that.
You can check that by adding a page to your webserver with the following content:
<?php
phpinfo();
Call that website in a webbroser and check whether there is any trace of the LDAP-extension. If not, you will need to get that extension. As there are many different ways to install it (from recompiling PHP to a call to your systems package-manager) I need more information on how your system - and especially PHP - has been installed.
Hope that helps!

curl shows installed in phpinfo, but still get undefined function: curl_init

Summary: curl is installed, but I still receive this error attempting to use it:
[Mon Nov 14 16:39:05 2011] [error] [client 75.145.113.155] PHP Fatal error: Call to undefined function curl_init() in /.../htdocs/system/application/libraries/paypal/Paypal_pro.php on line 619, referer: http://example.com/buy/checkout
from phpinfo:
Additional .ini files parsed /etc/php5/apache2/conf.d/curl.ini
extension_dir /usr/lib/php5/20090626+lfs
I've confirmed both /etc/php5/apache2/conf.d/curl.ini and /usr/lib/php5/20090626+lfs/curl.so actually do exist.
Here is the content of curl.ini:
extension=curl.so
When I view the phpinfo file I created, it shows a section for curl, but the features entry there is blank. Is that normal? If not, what would cause that? I'm using bunut and installed curl with the following command as root:
apt-get install php5-curl
It worked with no error. I've restarted apache a few times with no effect. I've done this a variety of times on other systems, both Ubunut and RedHat without difficulty, so I have no idea what is going wrong here.

Categories