Symfony 2: Install and enable the intl extension

2020-07-03 09:10发布

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.

7条回答
闹够了就滚
2楼-- · 2020-07-03 09:40

Follow these steps:

  1. 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%.

  1. Uncomment the following line on C:\wamp\bin\apache\apache2.4.9\bin\php.ini

    extension=php_intl.dll
    

It will work.

查看更多
冷血范
3楼-- · 2020-07-03 09:43

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

查看更多
倾城 Initia
4楼-- · 2020-07-03 09:56

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 !

查看更多
叛逆
5楼-- · 2020-07-03 09:58

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

查看更多
一夜七次
6楼-- · 2020-07-03 09:59

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

查看更多
Explosion°爆炸
7楼-- · 2020-07-03 10:02

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.

查看更多
登录 后发表回答