I had a Yii installation that was working fine up until today. I installed updates on my machine today after which this error was being thrown on all pages:
PHP Fatal Error – yii\base\ErrorException
Uncaught Error: Call to undefined function yii\web\mb_strlen() in /application/vendor/yiisoft/yii2/web/ErrorHandler.php:404
I ran composer update but the error persists.
I am using yii 2.0.7 on PHP 7 on Ubuntu 14.04. How do I fix this?
The error is a bit of a red herring since mb_strlen() is actually part of the mbstring php extension and not a function in yii2.
In php5 mbstring was part of libapache2-mod-php5.
It seems to be missing from libapache2-mod-php7. To fix this install the php7.x-mbstring package where x is your version:
sudo apt install php7.x-mbstring
You may need to restart Apache after this install.
For PHP7.1
Debian flavours
sudo apt-get install php7.1-mbstring
RedHat flavours
sudo yum install php7.1-mbstring
CentOS/RHEL-based
To get a list of available modules to check the version you need is available:
yum search mbstring
Installing mbstring module:
sudo yum install php-mbstring
This will install the correct version for you for your current php installation.
Related
I had php 5.4 on centOs and I have removed that and installed php 7.
Now One of my codes on server return the following error:
PHP Fatal error: Call to undefined function mb_internal_encoding()
And when I run yum install php-mbstring I got the following error:
Error: php70u-common conflicts with php-common-5.4.16-43.el7_4.x86_64
Error: php70u-json conflicts with php-common-5.4.16-43.el7_4.x86_64
I have removed and installed php7 several times but I didn't work.
It seems that centOs want to install an older version of the package but I don't know how to tell it to download the latest version of mbstring
To search the right MB-String for your PHP version try this command:
sudo yum list | egrep 'php' | grep 70
Change (70) by the specific version of PHP you do have installed in your server,this command will show you all the packages related to you PHP version.
This command will show :
ea-php70-php-mbstring.i686
ea-php70-php-mbstring.x86_64
Now you can install the version compatible with your system.I hope it will works for you.
yum install php72w-mbstring
will install the mbstring for 7.2
cannot-initialize-mbstring-with-php-7
If that does not work, you might only have package for 7.1 available
If that still does not work, you could remove the old 5.4 php common package and try again :
First search which old php packages are still installed on your machine :
yum list installed | grep php | grep 5.4
Then remove the old packages (for instance php-commom-5.4 . You can do the same with other ones if not used)
yum remove php-common-5.4
Then install php-mbstring again
yum install php-mbstring
I have laravel 5.3 site running on digitalocean with Ubunto 14.
I get this error when running composer to install a package:
"the requested PHP extension mbstring is missing from your system."
The thing is, it is already enabled, as confirmed by phpinfo:
mbstring
Multibyte Support enabled
Multibyte string engine libmbfl
HTTP input encoding translation disabled
libmbfl version 1.3.2
oniguruma version 5.9.6
Since I have php7.0 running, for kicks I tried
sudo apt-get install php7.0-mbstring
But it tells me
php7.0-mbstring is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
Really at a loss here. Ideas? Maybe I need to reinstall PHP? Where is composer looking to see if the extension is installed? Why would it n0t be seeing same info that phpinfo returns?
Thanks,
Brian
Basically, you need to install php-mbstring in your server.
sudo apt-get install php-mbstring
You need to install the specific php version using :
sudo apt-get install phpx.x-mbstring
Hope this works!!
Since my upgrade from PHP 5.5.9 to 5.6 on my Ubuntu 14.04 LTS server I have been getting problems with the expect library for PHP. It keeps displaying the Fatal error in the description. I believe the package that I need for this is libexpect-php5. Some installation checks confirm that it is installed:
root#k1:/etc/php5/conf.d$ dpkg --get-selections | grep -v deinstall | grep expect
empty-expect install
expect install
expect-dev install
expect-lite install
libexpect-ocaml install
libexpect-ocaml-dev install
libexpect-perl install
**libexpect-php5** install // installed right?
libexpect-simple-perl install
libghc-hspec-expectations-dev install
libghc-hspec-expectations-doc install
libghc-hspec-expectations-prof install
libnet-scp-expect-perl install
libtest-expect-perl install
netexpect install
python-pexpect install
python-pexpect-doc install
python3-pexpect install
and
root#k1:/etc/php5/conf.d$ expect -v
expect version 5.45
and the expect.so files:
root#k1:/usr/lib$ ls | grep expect
libexpect.so
libexpect.so.5
libexpect.so.5.45
and finally my /etc/php5/apache2/php.ini file:
extension=expect.so
I had to install libexpect-ph5 by downloading and installing the .deb file manually, because it was erring about an uninstallable dependency api... Now when I do and apt-get update && apt-get upgrade it keeps telling me this:
The following packages have been kept back:
libexpect-php5
Just installing that package does something, but the system will still keep the package back. This leaves me with a PHP version that doesn't know about the expect_popen() function.
How do I solve this?
I found out that Apache2 was loading the wrong php.ini file. Since the upgrade to PHP 5.6 the path has changed as well (of course).
Old location:
/etc/php/apache2/php.ini
New location:
/etc/php/5.6/apache2/php.ini
Along with that I had to specify the exact path to my expect.so extension in php.ini.
I recently switched to PHP 7 on my development server, which has worked just fine - until now.
Since I updated to PHP 7.0.3-10+deb.sury.org~trusty+1 (earlier today), the utf8_decode and utf8_encode functions are no longer accessible. They were, however, in previous versions of PHP7. When called, a fatal error is raised.
I read that these functions are provided by the mbstring extension, which I checked with var_dump(extension_loaded('mbstring')); is loaded.
How can I get the above functions to work again?
I had the same problem. Just install php7.0-xml package. Ubuntu 16.04:
sudo apt-get install php7.0-xml
Edit: Restart apache2 to load the new package.
On Ubuntu, you got the following message during the upgrade of PHP7:
php7.0 (7.0.3-6) unstable; urgency=medium
* Several extensions have been split into separate extension packages:
- php-dba - Database (dbm-style) Abstraction Layer
- php-mbstring - Multibyte String
- php-soap - SOAP
- php-xml - DOM, SimpleXML, WDDX, XML, XMLReader and XMLWriter
- php-zip - Zip
* The new packages are not installed automatically, so you will need to
install them by hand, if you use the functions in those modules.
* Most modules that have been builtin before are now included in
php7.0-common package and they are enabled by default for your
convenience. You can disable unneede modules via phpdismod tool.
-- Ondřej Surý <ondrej#debian.org> Mon, 22 Feb 2016 12:37:09 +0100
so it's one of those packages that's causing the problem. In this case, it's php-xml.
Note the
The new packages are not installed automatically
You can fix that by
sudo apt-get install php-xml
sudo apache2ctl graceful
If you are on CentOS, following command should work:
yum install php-xml
As the top voted answer did not work for me i found yet another package for php7 which (obvious by its name) fixed it for me
sudo apt-get install php7.0-mbstring
In Ubuntu 16.04 LTS, with php 5.6, try:
sudo apt-get install php5.6-xml
sudo service apache2 restart
The utf8_decode and utf8_encode functions are accessible in php 7:
function.utf8-encode - manual - php
This is because the php-xml package is missing in your php installation.
If your server is running Mandrake, enter "urpmi php-xml".
If your server is running EASYPHP on Windows, click on the EASYPHP logo to activate the php-xml module.
On debian or ubuntu try :
apt-get install php7.0-xmlrpc
I encountered the same problem and for me,
sudo apt-get install php-patchwork-utf8
and restarting the apache2 server solved the problem (on Ubuntu 16.04 LTS).
I want to install the v8js extension for PHP5.5 on Ubuntu 12.04 but can't make it working.
When I try to install the v8js extension version 0.2.0 (latest) with PECL, I have this message:
configure: error: libv8 must be version 3.24.6 or greater
ERROR: `/tmp/pear/temp/v8js/configure --with-v8js' failed
If I try to install an old version, I have a compilation error. This message is very similar to my issue: Install v8js for php on ubuntu
How can I fix this issue?
EDIT: I couldn't install it on Ubuntu 14.04 with PHP5.5, even with a PHP downgrade with PHPbrew to PHP 5.4. However, using Ubuntu 12.04 with PHP 5.4 works great. I didn't try the downgrade from PHP 5.5 to 5.4 on Ubuntu 12.04.
in case you can't find libv8-dev or libv8-dbg, you can find the correct version by run command
~$ apt-cache search libv8
libv8-3.14-dbg - V8 JavaScript engine - debugging symbols
libv8-3.14-dev - V8 JavaScript engine - development files for 3.14 branch
libv8-3.14.5 - V8 JavaScript engine - runtime library
libv8-dev - V8 JavaScript engine - development files for latest branch
then you can run
~$ sudo apt-get install libv8-3.14-dev libv8-3.14-dbg g++ cpp
then you can try to install v8js via pecl by running
~$ sudo pecl install v8js-0.2.0
if that command return error like this
configure: error: libv8 must be version 3.24.6 or greater
ERROR: `/tmp/pear/temp/v8js/configure --with-v8js' failed
you can try to install v8js-0.1.3 instead by running
~$ sudo pecl install v8js-0.1.3
then edit your php.ini to add v8js extension
~$ echo "extension=v8js.so" >> /etc/php5/cli/php.ini
Open your terminal/console
sudo apt-get install libv8-dev libv8-dbg g++ cpp
Make an update sudo apt-get update
Try sudo pecl install v8js-0.2.0 (or other version i.e.: sudo pecl install v8js-0.1.3)
Edit your php.ini (Check: Where is my php.ini file?) file by adding: extension=v8js.so.
Restart server
If it the extension still doesn't work, try to edit /etc/php5/conf.d/v8js.ini and add extension=v8js.so and restart server again.
Hope this helps.
These other answers work well and I used v8js-0.1.3 for the past 1.5 years but after needing to upgrade to PHP 7 I needed a better solution as v0.1.3 doesn't compile with PHP 7 (something to do with php_smart_str being renamed to php_smart_string).
After a couple hours of frustrating research and compiling libv8 myself, I didn't want to have to go through this whole process on every server I provisioned.
Anyway, I found this site which points you to a launchpad PPA site that provides a couple different ubuntu packages with the 5.1 and 5.2 libv8 libraries.
I ran these commands (please don't add repositories of 3rd party devs without understanding the risks).
sudo apt-add-repository ppa:pinepain/libv8-5.2
sudo apt-get update
sudo apt-get install libv8-5.2-dev
sudo pecl install v8js-1.1.0
(Thanks #JeyKeu for suggesting to add "apt-get update" to these commands)
I couldn't get v8js-1.3.0 or 1.2.0 to build, but 1.1.0 worked well. I checked the changelog and found that the latest updates are not necessary in my circumstance anyway.