I have php 7.4 installed on my macbook pro m1
% php -v
PHP 7.4.15 (cli) (built: Feb 26 2021 09:28:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.15, Copyright (c), by Zend Technologies
I'm trying to install the mongodb driver running:
sudo pecl install mongodb
But fails after a while:
mp/pear/temp/mongodb/src/contrib/ -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/temp/mongodb/php_phongo.c -fno-common -DPIC -o .libs/php_phongo.o
In file included from /private/tmp/pear/temp/mongodb/php_phongo.c:29:
In file included from /opt/homebrew/Cellar/php#7.4/7.4.15_1/include/php/ext/spl/spl_iterators.h:24:
/opt/homebrew/Cellar/php#7.4/7.4.15_1/include/php/ext/pcre/php_pcre.h:25:10: fatal error: 'pcre2.h' file not found
#include "pcre2.h"
^~~~~~~~~
1 error generated.
make: *** [php_phongo.lo] Error 1
ERROR: `make' failed
I tried with
arch -x86_64 sudo pecl install mongodb
but results in the same error.
Somebody knows how can I solve this please? Or if I can install the mongodb driver without using pecl. Thanks in advance.
I have finally solved my problem.
I followed these steps from https://github.com/mongodb/mongo-php-driver/issues/1159
After installing a newer PHP version where previously I used 7.3.24 and updated to 7.4.16.
Still had the same issue but diffrent file:
fatal error: 'pcre2.h' file not found #include "pcre2.h"
From this error I tried to check the files in the MacOs Big Sur File system and in the end I found where the pcre2.h is located, and oddly it was being called in the pcre folder, so I manually copied from the pcre2 folder to pcre
The solution that I used:
$cp /opt/homebrew/Cellar/pcre2/10.36/include/pcre2.h /opt/homebrew/Cellar/php\#7.4/7.4.16/include/php/ext/pcre/pcre2.h
Then, I installed mongodb using
$brew install mongodb
After that, I once again tried
$sudo pecl install mongodb
Finally, it worked. However, I'm not sure if this is a good way to solve the problem by manually adding a header file to the directory.
(Sorry I'm still new to the MacOs Environment, just bought a mac mini m1 last week for developing my programming skills)
If you were to install php multiple versions from homebrew make sure you are using the current version as you wanted to. You could check the version by using which php.
To switch from 7.4 to 5.6
$brew unlink php#7.4
$brew link php#5.6 --force
credits: https://www.markhesketh.com/switching-multiple-php-versions-on-macos/
New error
Success Installation:
There is a simpler way to fix the installation issue than symlinking the header file into PHP sources. When running pecl install, you can provide additional compile arguments via the CFLAGS environment variable. So, on the Apple Silicon platform, you can use the following command to get the extension to compile:
CFLAGS=-I/opt/homebrew/include pecl install mongodb
Note that this is only necessary on Apple Silicon, not on x64. It also works for other extensions that fail because of similar errors (e.g. apcu)
I had the same issue with PHP 7.3, I solved it just by running the following commands:
cp /opt/homebrew/Cellar/pcre2/10.38/include/pcre2.h /opt/homebrew/Cellar/php#7.3/7.3.31/include/php/ext/pcre/pcre2.h
Then installed it successfully:
sudo pecl install mongodb
I have finally solved my problem. I used PHP 8.1.7 - Mac Pro 2022 - Apple Silicon (M1)
My errors: fatal error: 'pcre2.h' file not found
The solution that I used:
1. brew install pcre2
2. ln -s /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /opt/homebrew/Cellar/php/8.1.7/include/php/ext/pcre/pcre2.h
Please check your path again when use `ln -s`
3. sudo pecl install mongodb
See more: Install pecl pear on MacOs - Link
Success Installation:
Hope it help you :) Thanks
cp /Applications/MAMP/Library/include/pcre2.h /Applications/MAMP/bin/php/php8.0.8/include/php/ext/pcre/pcre2.h
then run
sudo pecl install mongodb
If you use MAMP,
Based on #Kelwin Tantono's answer follow instructions to install mongodb then,
Firstly, check for the location of pcre2.h file by
cd /opt/homebrew/Cellar/pcre2/
In this directory find the folder with ls command, in my case it was 10.40 .
Change 10.40 value in the below code with the result of ls command.
Then, check your php version with moving to php directory at MAMP by
cd /Applications/MAMP/bin/php/
Change php8.0.8 value in the below code with your desired php version.
cp /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /Applications/MAMP/bin/php/php8.0.8/include/php/ext/pcre
Now you can install mongodb extension with below command after changing your working directory to
cd /Applications/MAMP/bin/php/php8.0.8/bin
sudo pecl install mongodb
Now, you should add extension=mongodb.so to php.ini file with
echo "extension=mongodb.so" > /Applications/MAMP/bin/php/php8.0.8/conf/php.ini
Do not forget to change php version.
Related
When I try to run the following command
pecl install imagick
Then the installation end up with:
imagemagick/7.0.11-9/lib -L/usr/local/Cellar/imagemagick/7.0.11-9/lib -lMagickWand-7.Q16HDRI -lMagickCore-7.Q16HDRI
cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/imagick.so -bundle .libs/imagick_file.o .libs/imagick_class.o .libs/imagickdraw_class.o .libs/imagickpixel_class.o .libs/imagickpixeliterator_class.o .libs/imagick_helpers.o .libs/imagick.o .libs/imagickkernel_class.o .libs/shim_im6_to_im7.o -lgomp -L/usr/local/Cellar/imagemagick/7.0.11-9/lib /usr/local/Cellar/imagemagick/7.0.11-9/lib/libMagickWand-7.Q16HDRI.dylib -L/usr/local/Cellar/little-cms2/2.12/lib -L/usr/local/opt/freetype/lib -L/usr/local/Cellar/glib/2.68.1/lib -L/usr/local/opt/gettext/lib /usr/local/Cellar/imagemagick/7.0.11-9/lib/libMagickCore-7.Q16HDRI.dylib -Wl,-rpath -Wl,/usr/local/Cellar/imagemagick/7.0.11-9/lib
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [imagick.la] Error 1
ERROR: `make' failed
The reason seems to be that the compilation of the last version of imagick (3.5.0) has changes that require this library. It's impossible to install a lower version because they are not compatible with PHP 8.0.
Any idea how to get rid of this error on macos?
Update 22 July 2021
As of 22 July 2021, version 3.5.1 is stable in the pecl channel and can be used to compile imagick for both PHP 7 and PHP 8.
pecl install imagick
The general command will not fail anymore
Old Answer
Version 3.5 currently can't compile on MAC because of missing/broken support for gomp of the MAC gcc compiler.
Best fix is to install version 3.4.4
pecl install imagick-3.4.4
More info here
There is a fix for this issue by manually installing the extension. The only issue with it is that it does not appear in the pecl installed extensions after the installation is done and can't be uninstalled from pecl. Nonetheless I'm providing the answer I found here:
Run the following commands
cd path/to/installation/is/going/to/be/made
pecl bundle imagick
cd imagick
mv config.m4 config.m4.bak
wget https://raw.githubusercontent.com/yyongpil/imagick/2a2b924b9d25c8ef4a677b72e6868fbc7c9e01cc/config.m4
To explain the previous process command line by command line:
Place yourself in the folder where you are going to make the install
Download and expand the source files
Enter the source folder
Backup the original config.m4 file for safety purposes
Download modified config.m4 file to fix gomp issue as explained here
And finally simply continue with the manual installation process
phpize
./configuration
make
sudo make install
After this, you should be good to go to use the latest imagick extension for PHP. For PHP 8.0 and imagick 3.5.0 the so file is located at /usr/local/lib/php/pecl/20200930/imagick.so
A new version has been tag and contains the build configuration fixed! You can install it with this command:
pecl install imagick-3.5.1
(without the version it should now work)
macOS Mojave 10.14.3
PHP 7.1.23
Prestashop 1.7.5.1
I tried to install PHP intl extension on my local server in order to use Prestashop.
I added extension=php_intl.so to etc/php.ini
When I try to install Prestashop I get Intl extension is not loaded.
$ php -m | grep intl
When I do $ php -m | grep intl, I get:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/pecl/20160303/php_intl.so' - d
lopen(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - dlopen
(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0
intl
It seems that the file php_intl.so doesn't exist.
$ sudo pecl install intl
I also tried $ sudo pecl install intland I get:
make: *** [php_intl.lo] Error 1
ERROR:make' failed`
$ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
I also tried $ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1 and it doesn't create the intl.so file.
How can I solve this problem?
Brew's PHP 7.1, 7.2 and 7.3 all have INTL enabled by default.
Most probably, you're just using your Mac OS' bundles version of PHP.
Run
ls -l $(which php)
to find out where the current PHP binary is located and whether it is symlinked to a Brew installation or not. In my case, for example:
lrwxr-xr-x 1 27 May 23 16:30 /usr/local/bin/php -> ../Cellar/php/7.3.5/bin/php
Meaning that my php is linked to Brew's 7.3.5 version.
If you are NOT using Brew's PHP, you'll see something like
-rwxr-xr-x 1 11169664 Mar 21 07:09 /usr/bin/php
Installing PHP through Brew
Find out whether you've already installed PHP:
brew list | grep php
If there is any output, and your version of PHP is present, go to step 2, or use step 1 to update PHP to the latest version.
1. Install Homebrew's PHP
brew install php#7.3
(or 7.2, 7.1). If Brew complains about not being able to find a formula, you might have messed with taps. Instead of php#7.3, you could try to supply the full path to the current php formula:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/php.rb
Still not working, check whether you are running a recent version of Homebrew brew --version.
Homebrew 2.1.3-31-geaf2370
Homebrew/homebrew-core (git revision fd1ef; last commit 2019-05-25)
Homebrew/homebrew-cask (git revision 16d50; last commit 2019-05-26)
2. Link Homebrew's PHP
Now, to have php 'in your path', there are two options.
a) Either homebrew's version must be linked from its install location (/usr/local/bin/Cellar/php....) to a directory in your path (e.g., /usr/local/bin). To do this, run:
brew link --force php#7.3
If you are not able to link, this is typically caused by set permissions or System Integrity Protection. In the first case, try sudo chown "$USER":admin /usr/local/bin/php.
b) Or, add the /usr/local/opt/php#7.3 directory (opt-prefix) to your $PATH variable. E.g., for Bash:
echo 'export PATH="/usr/local/opt/php#7.3/bin:/usr/local/opt/php#7.3/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
3. Validate installation
ls -l $(which php)
should show that php is linked to a Homebrew PHP installation in /usr/local/bin/Cellar.
php -v
should show the recently installed version of PHP. Try to restart your terminal if that's not the case.
php -i | grep -i intl
should show some information about the current install of intl.
If you're using webservers and/or PHP FPM, this is the time to restart those services. (Or restart your system, if you don't know how to do that and cannot figure out).
Possible issues
If you still get warnings about missing extensions (Unable to load dynamic library, etc.), then your php.ini is messed up.
Find the current location of php's ini
$ php -i | grep \.ini
Configuration File (php.ini) Path => /usr/local/etc/php/7.3
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/7.3/conf.d
Additional .ini files parsed => /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
....
Edit /usr/local/etc/php/7.3/php.ini and find the offending extension load (e.g., extension="myext.so"). Comment out those that cannot be found.
Homebrew permissions
Some argue that it's a good idea to chown /usr/local.
sudo chown -R "$USER":admin /usr/local
This will make installing things here, by hand and through Homebrew, a lot easier, but also a bit less secure too, since non-root processes are now allowed to write here too.
Your web-application is using a different version of PHP.
Make sure that it doesn't... The configuration of this depends on the used webserver. A first step would be to output the current PHP configuration in your web-application with <?php phpinfo();.
This explains steps for Apache.
Another way to get a webserver + PHP stack running quicly is using Laravel Valet.
Installing additional extensions
To install additional PHP extensions, use PEAR.
pear -V
should output the current PEAR and PHP version.
PEAR Version: 1.10.9
PHP Version: 7.3.5
Zend Engine Version: 3.3.5
Now, to install an extension, for example, PHP's yaml extension:
pear install yaml
I have seen a lot of answers about this problem and anyone helped me, but the last (of course). This is for XAMPP´s use.
Xcode is needed.
Download the version of php you use in xampp from php.net.
Extract it and open the extracted folder in a terminal using cd.
Change to subfolder ext/intl.
Run these commands to build the extension:
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install (password required)
Delete all files you downloaded and also the extracted folders.
Add to php.ini file in xampp/etc folder line
extension="intl.so"
Original link: https://community.apachefriends.org/viewtopic.php?p=255061&sid=27afc55649dfe6ea7b0824cb0bb8486b
Since php 7 it's not necessary load the extension php_intl.so, what do you need to do?, edit your php.ini and delete or comment the line that is loading the extension php_intl.so, after this reload your apache and try again.
There might be an issue with brew
You could try to use this as mentioned there:
brew tap kyslik/homebrew-php
brew install kyslik/php/php71-intl
i tried all but intl not working in mac so please uninstall xampp and install mamp it will work
So, on Pecl Official site ( https://pecl.php.net/package/intl ), it's clear that Intl package is not maintained anymore and has been superseded. Since PHP 5.3.0 you don't need to use Pecl to install intl extension, it's bundled with PHP.
But, it's missing on native instalation of PHP 7.1.24 on Mac OS Mojave.
if you wanna use only native apache and php pre-installed instead of using homebrew, do this:
Download PHP 7.1 from php.net, install XCode Command Line Tools, ICU (http://site.icu-project.org/), Autoconf, reinstall the developer tools header files, and finally install Intl extension using phpize.
Important: you'll have to disable SIP.
I am new on this editor and I would like to try it for php project.
I am trying to configure this package php-integrator-base in my atom ide, but I have this error:
The socket connection with the PHP server could not be established.
This means the PHP server could not be spawned. This is most likely an
issue with your setup, such as your PHP binary not being found, an
extension missing on your system, ...
This is my setup for this package:
This my php verion on my ubuntu distrib:
Anyone else have the same issue with this package ? Where am I wrong ?
EDIT
Since I have make the update of the package today I always have the same error but another one occured.
Indeed, an error message appears to notice that:
Core installed failed
When I start the atom editor I have this message too:
If you are on Unix system then go to :
cd $HOME/.atom/packages/php-integrator-base/core/
then you should have a directory with num version as name like 2.X.X. So :
cd 2.1.0 and ../composer.phar install
I am relevantly new to this IDE as well and had errors with installation of php-integrator-base. I am using Windows and it turned out that it was an issue with my environmental path. Try the following steps:
Add your Git binary path to your environmental path
Enable sqlite on your php.ini file by adding these: extension=php_sqlite3.dll and extension=php_pdo_sqlite.dll
If above steps do not work, try posting an issue at their GitHub repo.
There is a better solution, which solves this "identified" issue and others only visible when running Atom in --dev mode.
Sadly nobody ever pointed to the fact (or noticed) this issue is caused by packages differences in between PHP 7.0 and PHP 7.1. For some reason, for PHP 7.1 some packages still reference items related to PHP5.6, while some other packages are expecting everything to be PHP 7.x related.
The solution is to upgrade the PHP 7.0x to PHP 7.1.
In Ubuntu environments you can do that by running these commands:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt remove php7.0 (optional, only if you want to uninstall PHP7.0)
sudo apt install php7.1
Simply restart Apache by running:
sudo service apache2 restart
Then check your PHP version to confirm it has been upgraded:
php -v
You should get an output like this:
PHP 7.1.8-2+ubuntu16.04.1+deb.sury.org+4 (cli) (built: Aug 4 2017 13:04:12) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.8-2+ubuntu16.04.1+deb.sury.org+4, Copyright
(c) 1999-2017, by Zend Technologies
You may have to re-enable some extensions after upgrading to PHP 7.1. Atom may complain about these in specific (mbString, SQLite and DOM). Simply run these commands to install/activate them:
sudo apt install php7.1-mbstring
sudo apt install php7.1-sqlite
sudo apt install php7.1-xml
Don't forget to reactivate your old extensions as well (if any). For PHP 7.1 in most cases it is the same "command" just changing "php7" (or "php") to "php7.1".
Once you are done with PHP, navigate to Atom's PHP Integrator folder and check if the folder "3.0.0" exist:
.atom/packages/php-integrator-base/core/3.0.0/
If it doesn't exist go to https://gitlab.com/php-integrator/core/tree/3.0.0, download it and extract the contents of the compressed file in the 3.0.0 folder (you may have to create it):
Then, from inside .atom/packages/php-integrator-base/core/ you run:
composer install
Now, finally, Composer will be able to find the right packages and install all required dependencies.
Simply say "good bye" to the PHP Integrator errors that have been haunting you lately and enjoy your Atom, once again fully functional as it should be.
I hope it helps some fellow friends stop wasting time with lots of proposed solutions that exist online which in reality won't fix the real core of the problem. ;)
Following #Rei suggestion, I make an issue on theri github repo here.
To solve my problem, I follow step by step a manual installation of the package and then use composer inside the package itself to install the core folder.
If ./composer.phar install fails with a "missing sqlite extension", install php-sqlite extension:
sudo apt-get install php-sqlite3
I am trying to install the PHP Intl extension on my new Mac (El Capitan 10.11.4) using PECL, but there is a linking error during the make stage.
Here are the steps I took:
Installed PEAR to run on Mac
Compiled and installed the ICU library (version 51.2) into /usr/local/lib
Ran this command: sudo pecl install intl and there was an error (see below). I also tried compiling the extension directly from the PHP source code ("ext" folder) and received the same error message.
I am getting the following error:
ld: file not found: libicudata.51.dylib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [intl.la] Error 1
ERROR: 'make' failed
It looks like:
The file is missing (even though it knows the correct ICU library version to look for). Maybe it truly can't find the file. The -L switch and related switches appear to point to the correct path /usr/local/lib path.
Then, there is also some sort of architecture mismatch. So, I ran file libicudata.51.dylib and it appears to be the right architecture.
Here is what file retuned:
$ file /usr/local/lib/libicudata.51.dylib
/usr/local/lib/libicudata.51.dylib: Mach-O 64-bit dynamically linked shared library x86_64
Has anyone run across this before? Or know how to compile PHP's Intl extension on the new Mac Book Pro (El Capitan 10.11.4)? I a hoping for some hints on where to look next, because I am a bit stumped here.
Maybe you can try just this:
brew install php56-intl
You might consider looking at these threads (https://github.com/Homebrew/homebrew-php/issues/1701) and (https://github.com/Homebrew/homebrew-php/issues/1710). I tried to reproduce your error but I failed. The most probable reason would be an icu4c that is not linked.
Try using brew link --force icu4c
I tried using php70 and
sudo pecl install intl
failed. I tried using php56, everything ran smoothly.
Try running php -v master, something like this should show up
C02QH2D7G8WM:workspace userone$ php -v master
PHP 5.6.20 (cli) (built: Apr 1 2016 08:53:48)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
Try run:
brew install homebrew/php/php56-intl
I fixed this problem,here is my environment:
OS : El Capitan 10.11.4
PHP : php-7.0.5
icu : 55.1
the key point is reinstall ICU using --enable-rpath:
./configure --prefix=/opt/oss/icu --enable-release --enable-shared --enable-rpath --enable-tools
If you want to know why,please run as root
otool -L $YOUR_ICU_PREFIX/lib/libicudata.dylib
to check if the first library is absolute path.
I am on a 64bit Fedora 17 box, PHP5.4.8. I have Oracle Instant Client 11.2 installed. I am trying to install the pdo_oci package and I'm running into some issues.
I have the latest PDO_OCI package. I unpacked it and executed the following:
~$ > cd ../PDO_OCI-1.0
~$ > phpize
~$ > ./configure --with-pdo-oci=instantclient,/usr/lib/oracle/11.2/client64/lib
I get the error message:
"I'm too dumb to figure out where the include dir is in your instant client install"
As suggested by the pdo_oci manual in php.net, I created couple of paths with the minor version of the OIC as such
ln -s /usr/bin/include/oracle/11.2 /usr/include/oracle/11.2.0.1
Still I get the same error message. Does anybody have any idea?
The machine I'm running this on is not connected to the internet, so I have to run the installation using the previously downloaded packages.
I was running into the same problem. I an running centos 6.5 64bits, but fedora is a lot similar.
Supposing you already installed both basic and devel packages:
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.4.0-1.i386.rpm
You should specify just the "/usr" directory, as the configure looks for oci.h in this way in configure:
$PDO_OCI_IC_PREFIX/lib/oracle/$PDO_OCI_IC_VERS/client/include/oci.h
so, after editing config.m4 to be able to do a 11.2 install (reference for the url in the end), do this:
./configure --with-pdo-oci=instantclient,/usr,11.2
I followed this tutorial:
http://shiki.me/blog/installing-pdo_oci-and-oci8-php-extensions-on-centos-6-4-64bit/