A PHP plugin for the asdf version manager.
Original version of this plugin created by @Stratus3D
- 8.1
- 8.2
- 8.3
asdf plugin add php https://github.com/asdf-community/asdf-php.git
asdf install php <version>
If you are missing any required dependencies, the installer will provide details on which packages are missing and how to install them on your system.
Note
Composer is installed globally alongside PHP, by default.
Tip
If you require additional PHP extensions, you may install them using pecl
, which is also installed alongside PHP. For example:
pecl install redis
pecl install imagick
echo "extension=redis" > $(asdf where php)/etc/php.d/redis.ini
echo "extension=imagick" > $(asdf where php)/etc/php.d/imagick.ini
To install PHP on macOS, you'll need the Xcode command line tools and Homebrew.
While installing, you might see a message in the output about missing optional packages. asdf will continue building PHP. However, you may use Ctrl-C
to stop the build and install any optional packages you wish to include.
The message about optional packages will look something like this:
The following optional packages are missing:
libargon2-dev Enables use of Argon2 password hashing
libavif-dev Includes AVIF support for image processing with GD
libenchant-2-dev Includes Enchant spellcheck support
libffi-dev Includes foreign function interface support
libgdbm-dev Includes GNU dbm support
libkrb5-dev Includes Kerberos support in openssl_*
unixodbc-dev Includes ODBC support
libpq-dev Enables use of PostgreSQL
libpspell-dev Includes Pspell spellcheck support
libsnmp-dev Includes SNMP support
libtidy-dev Includes Tidy support
libwebp-dev Includes WEBP support for image processing with GD
libxpm-dev Includes XPM support for image processing with GD
libxslt1-dev Includes XSLT support
Use APT to install missing optional packages:
apt-get install -y libargon2-dev libavif-dev libenchant-2-dev libffi-dev libgdbm-dev libkrb5-dev unixodbc-dev libpq-dev libpspell-dev libsnmp-dev libtidy-dev libwebp-dev libxpm-dev libxslt1-dev
asdf-php: Missing some optional packages; see above.
Use Ctrl-C to cancel the build and install these, if you wish to include them.
asdf-php: Configuring the build (this can take a while)...
If you wish to exclude PEAR from your PHP installation, specify the PHP_WITHOUT_PEAR
variable with any value (except "no"), e.g.:
PHP_WITHOUT_PEAR=yes asdf install php <version>
Check the asdf documentation for instructions on how to install & manage versions.
Composer is installed globally alongside PHP, by default. If you install any Composer packages globally, you'll need to run the reshim
command. Afterward, you will be able to execute the command directly.
composer global require friendsofphp/php-cs-fixer
asdf reshim
php-cs-fixer --version
Licensed under the Apache License, Version 2.0.