DEV Community

Cover image for Install PHP 8.5 with ASDF on Arch Linux
Jean Dias
Jean Dias

Posted on

Install PHP 8.5 with ASDF on Arch Linux

This quick tutorial shows how to install ASDF Version Manager on Arch Linux and use it to install PHP 8.5.

Install Required Dependencies

First, install the required packages and build dependencies:

yay -S base-devel libpng postgresql-libs re2c gd oniguruma libzip libsodium
Enter fullscreen mode Exit fullscreen mode

You may also want to install additional common dependencies:

yay -S curl git openssl zlib libxml2 sqlite
Enter fullscreen mode Exit fullscreen mode

Install ASDF

Clone the ASDF repository:

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.18.0
Enter fullscreen mode Exit fullscreen mode

Add ASDF to your shell configuration.

Bash

echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

ZSH

echo '. "$HOME/.asdf/asdf.sh"' >> ~/.zshrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.zshrc
source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Verify installation:

asdf --version
Enter fullscreen mode Exit fullscreen mode

Add the PHP Plugin

Install the PHP plugin for ASDF:

asdf plugin add php https://github.com/asdf-community/asdf-php.git
Enter fullscreen mode Exit fullscreen mode

Install PHP 8.5

List available PHP versions:

asdf list all php
Enter fullscreen mode Exit fullscreen mode

Install PHP 8.5:

asdf install php 8.5.0
Enter fullscreen mode Exit fullscreen mode

Set PHP 8.5 as the global default:

asdf global php 8.5.0
Enter fullscreen mode Exit fullscreen mode

Reload your shell:

exec $SHELL
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

php -v
Enter fullscreen mode Exit fullscreen mode

Expected output:

PHP 8.5.x (cli)
Enter fullscreen mode Exit fullscreen mode

Useful ASDF Commands

List installed PHP versions:

asdf list php
Enter fullscreen mode Exit fullscreen mode

Install another PHP version:

asdf install php 8.4.0
Enter fullscreen mode Exit fullscreen mode

Switch globally:

asdf global php 8.4.0
Enter fullscreen mode Exit fullscreen mode

Switch locally for a project:

asdf local php 8.5.0
Enter fullscreen mode Exit fullscreen mode

Optional: Install Composer

After installing PHP, install Composer globally:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
rm composer-setup.php
Enter fullscreen mode Exit fullscreen mode

Verify:

composer --version
Enter fullscreen mode Exit fullscreen mode

Top comments (0)