-
install phpenv from it's instruction, including optional steps
-
install the related libraries, refer to this issue
-
normally, on macos, you cannot use plain install command, otherwise, you face the problem
configure: error: Please reinstall the [PACKAGE] distribution
-
so, install target php version available from php-build list
brew install autoconf bison bzip2 curl icu4c libedit libjpeg libiconv libpng libxml2 libzip openssl re2c tidy-html5 zlib
- then, use the
CONFIGURE_OPTS
together with installing command like this below
CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) \
--with-bz2=$(brew --prefix bzip2) \
--with-iconv=$(brew --prefix libiconv) \
--with-readline=$(brew --prefix readline) \
--with-libedit=$(brew --prefix libedit) \
--with-tidy=$(brew --prefix tidy-html5) \
--with-curl=$(brew --prefix curl)" phpenv install [VERSION]
for example, if you would like to install php 8.3.2, then go with this command
CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) \
--with-bz2=$(brew --prefix bzip2) \
--with-iconv=$(brew --prefix libiconv) \
--with-readline=$(brew --prefix readline) \
--with-libedit=$(brew --prefix libedit) \
--with-tidy=$(brew --prefix tidy-html5) \
--with-curl=$(brew --prefix curl)" phpenv install 8.3.2
- note that if you install php version 7.x, you have to put the option
--disable-phar
into theCONFIGURE_OPTS
also to avoid PEAR package PHP_Archive not installed Warning abortion problem,
CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) \
--with-bz2=$(brew --prefix bzip2) \
--with-iconv=$(brew --prefix libiconv) \
--with-readline=$(brew --prefix readline) \
--with-libedit=$(brew --prefix libedit) \
--with-tidy=$(brew --prefix tidy-html5) \
--with-curl=$(brew --prefix curl) \
--disable-phar" phpenv install 7.4.28
For me, installing some version (namely 7.4.13) seems mulfunction because I faced the problem of low level C compilation php-build error
make: *** Waiting for unfinished jobs....
In file included from /var/tmp/php-build/source/7.4.13/ext/intl/breakiterator/breakiterator_methods.cpp:22:
/var/tmp/php-build/source/7.4.13/ext/intl/breakiterator/codepointiterator_internal.h:42:17: error: virtual function 'operator==' has a different return type ('UBool' (aka 'signed char')) than the function it overrides (which has return type 'bool')
virtual UBool operator==(const BreakIterator& that) const;
~~~~~ ^
/opt/homebrew/Cellar/icu4c/73.2/include/unicode/brkiter.h:127:18: note: overridden virtual function is here
virtual bool operator==(const BreakIterator&) const = 0;
~~~~ ^
1 error generated.
make: *** [ext/intl/breakiterator/breakiterator_methods.lo] Error 1
So, I choose to skip to use this version and install another version instead.
EDIT
It seems that --disable-phar
option blocking the composer
installation. So, do not include this option when installing php version.
EDIT 2
phpenv uses php-build which build php 7.x from source which is very complex and these versions are deprecated. So, I decide to control the multiple versions of php with brew due to this instruction