Symfony 2: Install and enable the intl extension - php

I'm using XAMPP for Windows and decided to try out Symfony 2.
As soon as I get to Symfony Configuration page it recommends me to install and enable intl.
I tried reading PEAR's and PECL's guides, since I'm total 0 on this topic(started learning PHP recently), but nothing worked.
I found php_intl.dll inside my C:\xamp\php\ext. The php.ini's extension_dir= is set to "C:\xampp\php\ext". I was only missing the extension=php_intl.dll inside php.ini, so I added it.
Unfortunately it didn't work, and Symfony keeps asking me for intl.

Whenever you make changes to php.ini, remember to restart Apache. Otherwise the changes won't take effect. You can do this in the XAMPP Control Panel by clicking the stop/start button in the Apache module row.

http://php.net/manual/en/intl.requirements.php
This extension is bundled with PHP as of PHP version 5.3.0.
Alternatively, the PECL version of this extension may be used with all
PHP versions greater than 5.2.0 (5.2.4+ recommended).
also read my comment to your post above

Follow these steps:
Copy all the file names starting with "icu" from C:\wamp\bin\php\php5.5.12 and paste to C:\wamp\bin\apache\apache2.4.9\bin (I am using WAMP. Figure it out yourself for XAMP.)
You can try. Nothing will harm. If you feel the things are not working, you can delete them. I am sure it will work for you 100%.
Uncomment the following line on C:\wamp\bin\apache\apache2.4.9\bin\php.ini
extension=php_intl.dll
It will work.

For Linux users:
Installing php5-intl made it work for me
sudo apt-get install php5-intl
found here:
http://www.php.net/manual/en/intl.setup.php

For OS X users:
1.Normally, the PHP is automatically installed on OSX. So, if you would like to use the XAMPP, or whatever apache server, you must change the path point to XAMPP. You can check the path by using:
$ which php
(do not copy $ sign, it means than you should type this in Terminal, not php)
You should get: /Applications/XAMPP/xamppfiles/bin/php ,
if not, you will get /usr/bin/php.
This is OSX' php. So, you have to change it to XAMPP' php by using:
$ PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"
2.Run this command to download, unpack, compile and install ICU (you can choose different version is your Symfony required):
$ curl -sS -o /tmp/icu.tar.gz -L http://download.icu-project.org/files/icu4c/57.1/icu4c-57_1-src.tgz && tar -zxf /tmp/icu.tar.gz -C /tmp && cd /tmp/icu/source && ./configure --prefix=/usr/local && make && sudo make install
than run:
$ sudo pecl install intl
and specify where ICU libraries and headers can be found [DEFAULT] :
/usr/local
Pay attention to information in install report:
You should add "extension=intl.so" to php.ini
Don't forget to reboot Apache and check version:
<?php
if (extension_loaded('intl')) {
echo "PHP: " . PHP_VERSION . "<br>\n";
echo "ICU: " . INTL_ICU_VERSION . "<br>\n";
} else {
die('OOPS! The intl extension is not enabled!');
}
Partially taken from here but modified to get success Install PHP Internationalization extension (Intl) on XAMPP on Mac

To activate this extension in Xampp, just edit your php.ini (i.e. in C:\xampp\php directory) and remove the semicolon to uncomment this line :
;extension=php_intl.dll
Eventually don’t forget to restart Apache !

To solve this go to "c:\xampp\php\php.ini" open it in your editor and search for Dynamic Extensions then go down search for ;extension=php_intl.dll and enable it(remove ; to became like ) extension=php_intl.dll after that save your file php.ini and restart your localhost

Related

Exception: Call to undefined function mysqli_init() [duplicate]

I cannot find instructions about installing MySQLi on a Mac. Just to be clear, MySQL is up to date and I am running PHP 5. How do I install it? Where do I even get it from? Thanks for your help. I'll be giving an up vote and a check mark to whoever answers this!
Use php-mysqlnd instead of php-mysql. On Linux, to install with apt-get type:
apt-get install php-mysqlnd
MySQLi is part of PHP. There should be a php-mysqli type package available, or you can take the PHP source and recompile that mysqli enabled. You may already have it installed, but it's done as a module and is disabled. Check your php.ini for extension=mysqli.so or similar. it may be commented out, or the .so file is present in your extensions directory but not linked to PHP via that extension= directive.
This is how I installed it on my Debian based machine (ubuntu):
php 7:
sudo apt-get install php7.0-mysqli
php 5:
sudo apt-get install php5-mysqli
This article is clearly explained, how to install MySqli with EachApache. This works for me too.
To install mysqli using EachApache:
Login to WHM as 'root' user.
Either search for "EasyApache" or go to Software > EasyApache
Scroll down and select a build option (Previously Saved Config)
Click Start "Start customizing based on profile"
Select the version of Apache and click "Next Step".
Select the version of PHP and click "Next Step".
Chose additional options within the "Short Options List"
Select "Exhaustive Options List" and look for "MySQL Improved extension"
Click "Save and Build"
You are supposed to edit two lines in your php.ini file (i'm using windows for this example):
-The first one is regarding the extensions directory location. See below:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "C:/php/ext"
-The second one is regarding the extension itself:
extension=php_mysqli.dll
Only modifying (uncommenting) the extension line was not enough for me. Hope it helps
Here is the link for installation details:
http://php.net/manual/en/mysqli.installation.php
If you are using Windows or Linux:
- The MySQLi extension is automatically installed in most cases, when PHP & MySQL package is installed.
For Windows: 3 steps
Step1:
Just need to give the ext folder path in php.ini
Here
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "C:\php7\ext"
Step 2:
Remove the comment from
extension=php_mysqli.dll
Step 3:
restart the Apache server.
Since you are using a Mac, open a terminal, and
cd /etc
Find the php.ini, and sudo open it, for example, using the nano editor
nano php.ini
Find use control+w to search for "mysqli.default_socket", and change the line to
mysqli.default_socket = /tmp/mysql.sock
Use control+x and then hit "y" and "return" to save the file. Restart Aapche if necessary.
Now you should be able to run mysqli.
I recently ditched Xampp in favor of the native Apache on Mac Sierra because a new php requirement of a project. Sierra comes with php 5.6.25, but it doesn't run mysql_* out of the box, after a lot of googling, I found this site really help - https://php-osx.liip.ch. As it turns out php 5.6.25 does support mysql_* but wasn't enabled. Choose your version of php and download it, it generates a proper php.ini for your php, then you are good to go
sudo apt-get -y -f install php7.0-mysql
if you use ubuntu 16.04 (maybe and above) just do this
sudo phpenmod mysqli
sudo service php7.0-fpm restart
I had the same issue, I went to EasyApache4 from the WHM clicked on customize button then PHP Extension tab.. I selected and installed the extension php72-php-mysqlnd and my was solved
For mysqli on Docker's official php containers:
Tagged php versions that support mysqli may still not come with mysqli configured out of the box, You can install it with the docker-php-ext-install utility (see comment by Konstantin). This is built-in, but also available from the docker-php-extension-installer project.
They can be used to add mysqli either in a Dockerfile, for example:
FROM php:5.6.5-apache
COPY ./php.ini /usr/local/etc/php/
RUN docker-php-ext-install mysqli
or in a compose file that uses a generic php container and then injects mysqli installation as a setup step into command:
web:
image: php:5.6.5-apache
volumes:
- app:/var/www/html/
ports:
- "80:80"
command: >
sh -c "docker-php-ext-install mysqli &&
apache2-foreground"
Since many of these answers are old here is how to install mysqli for Easyapache 4.
If you try and search for mysqli under your PHP extensions in WHM you are not going to find it. The way to know which extension you need to install mysqli you will need to run this command in terminal
repoquery -q --whatprovides 'ea-php70-php-mysqli' | sort -V | tail -1
Should return something like
ea-php70-php-mysqlnd-0:7.0.33-1.1.4.cpanel.x86_64
All you really need from this is mysqlnd copy it
To install mysqli using EachApache4:
Login to WHM.
Search for "EasyApache4"
At the top look for "Currently Installed Packages" and click on the button "Customize"
On the left panel click "PHP Extensions"
Search for mysqlnd
You should see something like "php70-php-mysqlnd"
Toggle the switch to enable it
On the left panel click on review
At the bottom click "Provision"
You're Done
On php 5.3.0 and later version you dont need to specially install mysqli on windows.
Rather follow simple steps as shown below.
Locate php.ini file [ if not there it means you have not copied php.ini-development or php.ini-production file as php.ini to make your configurations ]
There are 2 things to be done
1. Uncomment and set right path to extension_dir = "ext" Basically set the path where you find ext folder in php even if its in same folder from where you are running php-cgi.ex
uncomment mysqli library extention extension=mysqli
Note: uncommenting in this php.ini file is by removing starting ; from the line.
to solve this issue you should Run
sudo apt-get install php7.4-mysqli

Magento PHP Extension intl - XAMPP

I tried to install Magento on localhost (XAMPP) for the first time today. As Magento installer does the Readiness Check an error occurs, as it is missing PHP Extension intl. I have done research, but all I can find is to remove ; from ";extension=php_intl.dll" in php.ini in etc folder. This does not work (tried to restart XAMPP and the computer several times)
This is driving me crazy, please help.
I am on macOS Sierra.
First of all, you should check with phpinfo() method to check intl loaded or not. some time may this loaded bud you are in the mistakes.
after that, check php_intl.dll existin this folder : "\xampp\php\ext"
if all of these are ok, you may check log files.
UPDATE:
Base on your update about OS,if you have homebrew available and have PHP7:
$ brew install php70-intl // For PHP7.0
$ brew install php71-intl // For PHP7.1
For PHP5.5:
$ brew install php55-intl
Re-open your terminal window to ensure it works right in your session. To see if it loaded via your CLI interpreter:
$ php -m | grep intl
Or:
$ php -i "(command-line 'phpinfo()')" | grep intl
Source: https://daveismyname.blog/blog/install-php-intl-on-mac-using-homebrew
You need to check your correct php.ini file and also create a php file with a function phpinfo() and run this file and check the extension that are not installed.
To enable/installed these extension go to php.ini file and uncomment those extension.
save this file and restart the apache/xampp
I hope it will work for you.

Enable MCrypt using MAMP

I'm using MAMP and ive installed a fresh version of Opencart, its telling me i dont have MCrypt enabled, when i go to terminal and type:
php -m | grep mcrypt
output: mcrypt
I can locate the library but it doesn't seem to be enabled.
That fact that php -m | grep mcrypt returns mcrypt, means the mcrypt library is INSTALLED and ENABLED.
Although it may just be enabled for CLI.
You can try editing the PHP.ini file and adding the following line under the ; Extensions section:
extension=mcrypt.so
Restart Apache / MAMP after saving php.ini file.
To find the correct php.ini file to edit, run the following command line:
php --info | grep php.ini
(If the line already exists, you may just need to remove the ; thats in front of it.)
I have tried so many ways but had no luck.
After a lot of trials finally came up with a solution.
Go to bin directory inside current active PHP version directory. In my case it is /Applications/MAMP/bin/php/php7.2.8/bin
It might be different in your case. Now run the below command with sudo
sudo ./pecl install channel://pecl.php.net/mcrypt-1.0.1
Now You should add extension=mcrypt.so to php.ini
Restart MAMP Service and check if it is working.
I had this issue following upgrading to MAMP 5.1 and using PHP 7.1.20...
The issue I found was not that MAMP PHP did not have mcrypt installed, it certainly does come bundled.
The issue was that the MAMP PHP configuration option "Make this version available on the command line" was NOT working and so the version of PHP I was using on the command line [in my case] was the macOS default PHP 7.1.16 without mcrypt (the version included in macOS by default)
Reverting to the old cli php alias meant the correct MAMP version of PHP was used on the command line
Added to .bash_profile
alias php='/Applications/MAMP/bin/php/php7.1.20/bin/php'
try in console
pecl install mcrypt
Using Brew:
Install mcrypt: brew install mcrypt
In Mamp: File -> Edit Template -> PHP (php.ini)-> {PHP version}
Find 'Dynamic Extensions' in the text and add the following below (after the lines starting with ';'):
extension=mcrypt.so
Save, restart and test (with php -i | grep mcrypt for example)

How to install MySQLi on MacOS

I cannot find instructions about installing MySQLi on a Mac. Just to be clear, MySQL is up to date and I am running PHP 5. How do I install it? Where do I even get it from? Thanks for your help. I'll be giving an up vote and a check mark to whoever answers this!
Use php-mysqlnd instead of php-mysql. On Linux, to install with apt-get type:
apt-get install php-mysqlnd
MySQLi is part of PHP. There should be a php-mysqli type package available, or you can take the PHP source and recompile that mysqli enabled. You may already have it installed, but it's done as a module and is disabled. Check your php.ini for extension=mysqli.so or similar. it may be commented out, or the .so file is present in your extensions directory but not linked to PHP via that extension= directive.
This is how I installed it on my Debian based machine (ubuntu):
php 7:
sudo apt-get install php7.0-mysqli
php 5:
sudo apt-get install php5-mysqli
This article is clearly explained, how to install MySqli with EachApache. This works for me too.
To install mysqli using EachApache:
Login to WHM as 'root' user.
Either search for "EasyApache" or go to Software > EasyApache
Scroll down and select a build option (Previously Saved Config)
Click Start "Start customizing based on profile"
Select the version of Apache and click "Next Step".
Select the version of PHP and click "Next Step".
Chose additional options within the "Short Options List"
Select "Exhaustive Options List" and look for "MySQL Improved extension"
Click "Save and Build"
You are supposed to edit two lines in your php.ini file (i'm using windows for this example):
-The first one is regarding the extensions directory location. See below:
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "C:/php/ext"
-The second one is regarding the extension itself:
extension=php_mysqli.dll
Only modifying (uncommenting) the extension line was not enough for me. Hope it helps
Here is the link for installation details:
http://php.net/manual/en/mysqli.installation.php
If you are using Windows or Linux:
- The MySQLi extension is automatically installed in most cases, when PHP & MySQL package is installed.
For Windows: 3 steps
Step1:
Just need to give the ext folder path in php.ini
Here
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "C:\php7\ext"
Step 2:
Remove the comment from
extension=php_mysqli.dll
Step 3:
restart the Apache server.
Since you are using a Mac, open a terminal, and
cd /etc
Find the php.ini, and sudo open it, for example, using the nano editor
nano php.ini
Find use control+w to search for "mysqli.default_socket", and change the line to
mysqli.default_socket = /tmp/mysql.sock
Use control+x and then hit "y" and "return" to save the file. Restart Aapche if necessary.
Now you should be able to run mysqli.
I recently ditched Xampp in favor of the native Apache on Mac Sierra because a new php requirement of a project. Sierra comes with php 5.6.25, but it doesn't run mysql_* out of the box, after a lot of googling, I found this site really help - https://php-osx.liip.ch. As it turns out php 5.6.25 does support mysql_* but wasn't enabled. Choose your version of php and download it, it generates a proper php.ini for your php, then you are good to go
sudo apt-get -y -f install php7.0-mysql
if you use ubuntu 16.04 (maybe and above) just do this
sudo phpenmod mysqli
sudo service php7.0-fpm restart
I had the same issue, I went to EasyApache4 from the WHM clicked on customize button then PHP Extension tab.. I selected and installed the extension php72-php-mysqlnd and my was solved
For mysqli on Docker's official php containers:
Tagged php versions that support mysqli may still not come with mysqli configured out of the box, You can install it with the docker-php-ext-install utility (see comment by Konstantin). This is built-in, but also available from the docker-php-extension-installer project.
They can be used to add mysqli either in a Dockerfile, for example:
FROM php:5.6.5-apache
COPY ./php.ini /usr/local/etc/php/
RUN docker-php-ext-install mysqli
or in a compose file that uses a generic php container and then injects mysqli installation as a setup step into command:
web:
image: php:5.6.5-apache
volumes:
- app:/var/www/html/
ports:
- "80:80"
command: >
sh -c "docker-php-ext-install mysqli &&
apache2-foreground"
Since many of these answers are old here is how to install mysqli for Easyapache 4.
If you try and search for mysqli under your PHP extensions in WHM you are not going to find it. The way to know which extension you need to install mysqli you will need to run this command in terminal
repoquery -q --whatprovides 'ea-php70-php-mysqli' | sort -V | tail -1
Should return something like
ea-php70-php-mysqlnd-0:7.0.33-1.1.4.cpanel.x86_64
All you really need from this is mysqlnd copy it
To install mysqli using EachApache4:
Login to WHM.
Search for "EasyApache4"
At the top look for "Currently Installed Packages" and click on the button "Customize"
On the left panel click "PHP Extensions"
Search for mysqlnd
You should see something like "php70-php-mysqlnd"
Toggle the switch to enable it
On the left panel click on review
At the bottom click "Provision"
You're Done
On php 5.3.0 and later version you dont need to specially install mysqli on windows.
Rather follow simple steps as shown below.
Locate php.ini file [ if not there it means you have not copied php.ini-development or php.ini-production file as php.ini to make your configurations ]
There are 2 things to be done
1. Uncomment and set right path to extension_dir = "ext" Basically set the path where you find ext folder in php even if its in same folder from where you are running php-cgi.ex
uncomment mysqli library extention extension=mysqli
Note: uncommenting in this php.ini file is by removing starting ; from the line.
to solve this issue you should Run
sudo apt-get install php7.4-mysqli

Install Tidy, PHP

I guess when php was installed on my box --with-tidy arg was not included.
When browsing my php.ini the line:
;extension=php_tidy.dll
is missing.
How can I add the module to my php install? Note I tried adding:
extension=php_tidy.dll
but with no luck.
I checked the docs but all they say is:
This extension is bundled with PHP 5 and greater, and is installed using the --with-tidy configure option.
On Ubuntu, you can add tidy to your php5 installation by running this command in a terminal:
$ sudo apt-get install php5-tidy
If you want to check if it is already installed or validate that the command above worked:
$ php -i | grep libTidy
libTidy Release => 25 March 2009 // means tidy is installed
To install both php5 and tidy at the same time, use this command (as an alternative to the "--with-tidy" configuration option):
$ sudo apt-get install php5 php5-tidy
For PHP 7 just run
sudo apt-get install php-tidy
And restart Apache, That's it :)
Update: Thanks to #Arnis Juraga
For the version above PHP 7, you can mention the version code as follows.
apt-get install php7.4-tidy
I was having the same trouble, and wrote up my solution here:
Installing Tidy 2.0 PHP extension on Ubuntu 10.10
http://web.onassar.com/blog/2010/11/16/installing-tidy-2-0-php-extension-on-ubuntu-10-10/
It works on newer versions of Ubuntu as well.
While it may not be the most direct route, it works well.
I hope it helps others.
Put that line in php.ini next to the other extension=...dll lines and make sure php_tidy.dll is in the directory configured in php.ini under extension_dir.
In ubuntu: you need to run the following command in terminal
sudo apt-get install php5-tidy
and the restart the server
sudo service apache2 restart.
For those who are having trouble enabling Tidy extension for PHP (using PHP handler for Apache server) on Windows (WAMP server), please note that you may be editing the wrong php.ini file. Assuming that WAMP server is installed in C:\wamp[ver]\ where [ver] is a variable version number.
File that you're probably editing:
C:\wamp[ver]\bin\php\php[ver]\php.ini
File that you must edit:
C:\wamp[ver]\bin\apache\apache[ver]\bin\php.ini
You also might want to make sure what's the correct php.ini file to edit by creating an info php file and add this code to it:
<?php phpinfo();
Then look for Loaded Configuration File string.
Finally make sure you uncomment this line within the correct php.ini file:
extension=tidy

Categories