114

I am trying to use composer.json file. but, when I am trying to run command 'composer install' in my path/project/, I am getting an error:

enter image description here

I have already configured my wamp for 'extension=php_intl.dll' and copied all icu*.dll in 'D:\wamp\bin\apache\apache2.2.22\bin' from 'D:\wamp\bin\php\php5.3.13' and it's showing in phpinfo():

enter image description here

without copy icu*.dll also works and showing in phpinfo();

Kindly, let me know if I have intl install on my wamp and composer install on my pc then why I am getting this error. really, it is so annoying.

Here is my details:

  1. OS: windows 7 (64)
  2. PHP: 5.3.13
  3. Apache:2.2.22
  4. Composer: installed by executable file
  5. Pear: installed (latest)
  6. PHPUnit: installed (latest)

My composer.json is as below:

{
    "name" : "sebastian/money",
    "description" : "Value Object that represents a monetary value (using a currency's smallest unit)",
    "keywords" : ["money"],
    "homepage" : "http://www.github.com/sebastianbergmann/money",
    "license" : "BSD-3-Clause",
    "authors" : [{
            "name" : "Sebastian Bergmann",
            "email" : "sebastian@phpunit.de"
        }
    ],
    "require" : {
        "php" : ">=5.3.3",
        "ext-intl" : "*"
    },
    "require-dev" : {
        "phpunit/phpunit" : "~4.0"
    },
    "autoload" : {
        "classmap" : [
            "src/"
        ]
    },
    "extra" : {
        "branch-alias" : {
            "dev-master" : "1.3.x-dev"
        }
    }
}

Let me know if any other details is required..

Any feedback/help would be highly appreciated.

Nono
  • 6,986
  • 4
  • 39
  • 39

11 Answers11

157

I encountered this using it in Mac, resolved it by using --ignore-platform-reqs option.

composer install --ignore-platform-reqs

After installing with this method, if the package that defines the requirement attempts to use any functions from the specified PHP extension, it will fail irrevocably.

miken32
  • 42,008
  • 16
  • 111
  • 154
Sky
  • 7,343
  • 8
  • 31
  • 42
  • 1
    Actually worked for me better than the other solutions. May have to add that --ignore-platform-reqs is a composer option for the ones who like to try it also :) – David Pinezich Dec 27 '17 at 09:03
  • Done it on Lubuntu - there's nothing more legit than this – daniel Warui Feb 12 '19 at 18:25
  • 5
    Can someone give some input about any drawback related to the use of this flag? – S. Dre Dec 16 '21 at 09:32
  • 1
    @S.Dre as Healyhatman explained 2 answers below, this ignores apparently ignores the problem, I've found this [old ressource](https://hannesvdvreken.com/2015/01/18/composer-ignore-platform-reqs-flag/), it states that this flag disables some kind of check between the PHP system installed and what extensions are available, hence could somewhat ignore the problem, but it is nuanced, there are some uses cases for this flag where it is useful, the blog post states those use cases. – AkechiShiro Apr 27 '22 at 23:14
  • 1
    I figured so @AkechiShiro, any flag with *ignore* should be treated with a grain of salt. – S. Dre Apr 28 '22 at 06:34
  • @S.Dre the package defined this requirement because it uses the extension somewhere. If you ignore the requirement, your web page will die as soon as it hits the line where the extension is used. This is bad advice. – miken32 Aug 09 '22 at 15:37
  • Yes @miken32. A red flag rose in my head as soon as I saw that flag (no pun intended). That's why I asked. Something told me this was kind of wrong. – S. Dre Aug 10 '22 at 07:11
134

PHP uses a different php.ini for command line php than for the web/apache php. So you see the intl extension in phpinfo() in the browser, but if you run php -m in the command line you might see that the list of extensions there does not include intl.

You can check using php -i on top of the output it should tell you where the ini file is loaded from. Make sure you enable the intl extension in that ini file and you should be good to go.

For php.ini 5.6 version (check version using php -v)

;extension=php_intl.dll 
; remove semicolon
extension=php_intl.dll

For php.ini 7.* version

;extension=intl
; remove semicolon
extension=intl
miken32
  • 42,008
  • 16
  • 111
  • 154
Seldaek
  • 40,986
  • 9
  • 97
  • 77
  • 7
    Thank you so much Seldaek, You are right, There is different PHP.ini for CLI. Its 'D:\wamp\bin\php\php5.3.13\php.ini' and for WEB its 'D:\wamp\bin\apache\apache2.2.22\bin\php.ini'. So, I had to edit CLI php.ini too. Now its working. if anybody want to know what php.ini CLI using then just run php -i on CMD or better way $ php -i > php.txt. it will save output in php.txt file then you can know php.ini path by 'Loaded Configuration File => '. Ciya!! and once again Thanks allot!! – Nono Mar 12 '14 at 16:27
  • 5
    `php --ini` will show CLI configuration file names. – Mukesh Chapagain Jun 24 '15 at 10:11
  • On Debian/Ubuntu-like systems we can install `mbstring` extension using the command: `sudo apt-get install php-mbstring` – Sasha MaximAL May 16 '16 at 08:31
  • 1
    In my case on Ubuntu 16.04 running a LAMP stack: **Un-comment** (i.e. remove the suffix ; symbol) `extension=php_intl.dll` in the php.ini of **web/apache php** && **Leave** the php.ini of **php-cli** as it was _(because doing the same for php-cli made php through this error in terminal: PHP Warning: PHP Startup: Unable to load dynamic library... )_ || And all worked well after this! – Vinay Vissh Mar 27 '17 at 16:00
  • My paths states: Loaded Configuration File => (none) How dod I find the php.ini file now? Why does it say none... :( – pinkp Apr 22 '20 at 15:15
  • It gives me system error ( MSVCP140.dll is missing from your computer). I have XAMPP v3.2.4 on Windows. – Mr. Aniket Nov 18 '20 at 15:27
  • I don't save as a php.ini file . get system error " You Don't have permission to open this file " – Sarthak Raval Aug 06 '21 at 16:44
  • Removing semicolon before extension=intl line in php.ini file worked for me. – dipakbari4 Dec 15 '21 at 19:39
  • Great. Thank you so much. My PHP 7.x ;extension=intl – Bang Andre Dec 19 '21 at 03:39
  • `php -i | grep "Loaded Configuration File"` This will show the loaded config file path – Ali Raza Apr 06 '22 at 11:23
44

In linux (Debian Jessie for example):

apt-get install php7.0-intl

will make the job to you due will create a simbolic link to it.

  • thanks, make sure the module is installed first, then do what this answer says: https://stackoverflow.com/a/22345369/4628115 – CybeX Apr 30 '20 at 02:16
  • Should be noted that the version of PHP that you want to install this for should be adjusted. Example if you wanted to install it for PHP 7.3 you'd do: sudo apt-get install php7.3-intl – Uriahs Victor Jul 13 '20 at 23:25
16

To enable intl extension follow the instructions below.

You need enable extension by uncommenting the following line extension=php_intl.dll in the C:\xampp\php\php.ini file. Once you uncomment the extension=php_intl.dll, then you must restart apache server using XAMPP control panel.

//about line 998
;extension=php_intl.dll 
change as
extension=php_intl.dll

(Note: php.ini file mostly in the following directory C:\xampp\php)

Restart xampp

matinict
  • 2,411
  • 2
  • 26
  • 35
3

just remove them

"ext-intl" : "*"

from your composer.json file.

Because sometimes for some helper functions, the IDE complains that the extension is missing from the composer.json file. Immediately press Alt+Enter to add it to the composer. But that doesn't mean that composer will count them in. The composer will complain next time while doing some operations. So that, we should not blindly type Alt+Enter rather than installing them manually in composer by doing composer install <package-name>.

As I think you have entered it manually, you should remove it, then install it in proper procedure composer install <package-name>

Or else you can run composer update to count that added dependencies in.

S K R
  • 552
  • 1
  • 3
  • 16
2

If You have got this error while running composer install command, don't worry. Steps to be followed and requirements:

  • Step1: Go to server folder such as xampp(or) wampp etc.
  • Step2: open php folder inside that and go to ext folder.
  • Step3: If you find a file named as php_intl.dll no problem.

Just go to php.ini file and uncomment the line

From:

;extension=php_intl.dll

To:

extension=php_intl.dll
  • Step4: restart xampp, thats it

Note: If you don't find any of the file named as php_intl.dll, then you need to upgrade the PHP version.

ochs.tobi
  • 3,214
  • 7
  • 31
  • 52
ManojKiran A
  • 5,896
  • 4
  • 30
  • 43
  • I have XAMPP v3.2.4 on Windows. I have php_intl.dll in 'ext folder'. but, In php.ini file, there is ';extension=intl' line, I have uncommented it & follow your instruction. It gives me system error ( MSVCP140.dll is missing from your computer). – Mr. Aniket Nov 18 '20 at 15:35
2

(with xampp server)open php.ini in ".\xampp\php"

change ;extension=intl to extension=intl

huu duy
  • 2,049
  • 21
  • 31
1

This is bit old question but I had faced same problem on linux base server while installing magento 2.

When I am firing composer update or composer install command from my magento root dir. Its was firing below error.

Problem 1
    - The requested PHP extension ext-intl * is missing from your system. Install or enable PHP's intl extension.
  Problem 2
    - The requested PHP extension ext-mbstring * is missing from your system. Install or enable PHP's mbstring extension.
  Problem 3
    - Installation request for pelago/emogrifier 0.1.1 -> satisfiable by pelago/emogrifier[v0.1.1].
    - pelago/emogrifier v0.1.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system.
   ...

Then, I searched for the available intl & intl extensions, using below commands.

yum list php*intl
yum install php-intl.x86_64  

yum list php*mbstring
yum install php-mbstring.x86_64

And it fixed the issue.

Rohan Patil
  • 1,865
  • 1
  • 23
  • 36
0

In latest XAMPP version; You need to find only intl(Line no 912)in php.ini file. Change ;extension=intl To extension=intl

0

In my case, I am using ubuntu, run this command, it will be solved if your system is also ubuntu.

sudo apt-get install php-intl
Mochi
  • 123
  • 8
0

I have faced the same issue on my server. And it is mainly happened due to miss-match of php version between server version and your system version. I am using Nginx and checked on all my project configuration files, it uses php8.0 but on my terminal it shows php.8.1. Actually my application needs php8.0. The following steps resolved my issue.

To see all my running php versions

sudo update-alternatives --config php 

It shows the following page php all versions page

Selecting php8.0 for my application. Run the command to see Nginx scripts are ok

sudo nginx -t

Then reload the Nginx

sudo systemctl reload nginx

Finally go to your project directory and update or install your composer

composer update

It has been resolved my issue, I expect same will resolve yours.

Ziaur Rahman
  • 1,148
  • 11
  • 24