PHP Startup: Unable to load dynamic library 'intl' (tried: /opt/homebrew/lib/php/pecl/20190902/intl

3k views Asked by At

I am setting the environment for the use of CodeIgniter4. I want to use "extension=intl" or "extension=mbstring" in php.ini

php.ini

extension=intl
;extension=imap
;extension=ldap
extension=mbstring

After that, when the local server is executed, the following error is output.

PHP Warning:  PHP Startup: Unable to load dynamic library 'intl' (tried: /opt/homebrew/lib/php/pecl/20190902/intl (dlopen(/opt/homebrew/lib/php/pecl/20190902/intl, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/intl' (no such file), '/usr/local/lib/intl' (no such file), '/usr/lib/intl' (no such file)), /opt/homebrew/lib/php/pecl/20190902/intl.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/intl.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/intl.so' (no such file), '/usr/local/lib/intl.so' (no such file), '/usr/lib/intl.so' (no such file))) in Unknown on line 0
[Wed Feb  2 16:50:09 2022] PHP Warning:  PHP Startup: Unable to load dynamic library 'mbstring' (tried: /opt/homebrew/lib/php/pecl/20190902/mbstring (dlopen(/opt/homebrew/lib/php/pecl/20190902/mbstring, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/mbstring' (no such file), '/usr/local/lib/mbstring' (no such file), '/usr/lib/mbstring' (no such file)), /opt/homebrew/lib/php/pecl/20190902/mbstring.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/mbstring.so, 0x0009): tried: '/opt/homebrew/lib/php/pecl/20190902/mbstring.so' (no such file), '/usr/local/lib/mbstring.so' (no such file), '/usr/lib/mbstring.so' (no such file))) in Unknown on line 0

My extesion_dir's value is "/opt/homebrew/lib/php/pecl/20190902"

Diretory Tree in 20190902

.
└── xdebug.so

If so, I think it is an error that occurred because extension does not exist, but it is loaded when checked through actual phpinfo().

enter image description here

enter image description here

And run php -m | grep "intl", it is exist

2

There are 2 answers

2
cfv1000 On

phpinfo and php -m are different. running php in CLI can load a different ini file from the ini file loaded by your webserver configuration. Try running your phpinfo script using the built-in webserver (php -S localhost:88 phpinfo.php). Then access localhost:88 in the webbrowser.

2
Steven Horton On

I was running into this issue myself with homebrew and php on my m1 macbook.

It was compiled into the PHP binary that is installed by homebrew, which means it's loaded without mentioning it in the ini file. This means you can't load it manually, and attempting to do so will cause a startup error that will show as a warning when running PHP from the command-line interface.

The best thing to do is just remove the line in the ini to load that module, since attempting to load it will fail.