Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I enable the intl extension in CakePHP?

I am using CakePHP 3 and MAMP Pro server for my project. When I am trying to bake the cake, this error shows up:

Fatal error: You must enable the intl extension to use CakePHP.

I have even included intl.so and extension=php_intl.dll in my php.ini file but couldn't figure out solution for this error.

like image 538
Srinidhi Karnati Avatar asked Aug 09 '17 16:08

Srinidhi Karnati


2 Answers

this issue was happening to me some days ago. I had installed Ubuntu 18.04 and php 7.1.

I was trying to run the comman php cake.php bake in orden to use cakephp's console but I was getting the following error message:

  • You must enable the intl extension to use CakePHP.

This extension (intl) was installed for php 7.1 (php7.1-intl) but this message was appearing every time I used php cake.php bake

After some google searches, I saw that I have to install the extension but with the following command:

sudo apt-get install php-intl

The same issue happened with mbstring extension, I used the command:

sudo apt-get install php-mbstring

then I restarted the apache server with:

sudo service apache2 restart
like image 108
Carlos Espinoza Avatar answered Sep 27 '22 17:09

Carlos Espinoza


It's difficult to pinpoint exactly what's wrong without seeing your system setup. However based on what was said in the question, you may be setting up the intl extension incorrectly.

First off, if your OS is Linux/macOS and the PHP extension is a shared library (i.e. has a .so extension) then the php.ini entry should be extension=intl.so not extension=php_intl.dll. Also make sure the intl.so file is in the directory configured under the ini entry extension_dir. Otherwise make sure the extension ini entry is fully qualified (e.g. extension=/path/to/extension/dir/intl.so).

If you are using a Linux OS that has a package manager such as Debian/Ubuntu, you may be able to more easily install the extension for the PHP packaged for that distro. For example, in Ubuntu/Debian the package php5-intl provides the intl extension for PHP5 (I assume it's something similar for PHP7 if you've enabled those repos).

If you build PHP from source, you can try bundling the extension into your PHP. See the instructions from the manual.

like image 36
Roger Gee Avatar answered Sep 27 '22 17:09

Roger Gee