VOOZH about

URL: https://dev.to/jeanmfdias/install-php-85-with-asdf-on-arch-linux-25g8

⇱ Install PHP 8.5 with ASDF on Arch Linux - DEV Community


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

You may also want to install additional common dependencies:

yay -S curl git openssl zlib libxml2 sqlite

Install ASDF

Clone the ASDF repository:

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.18.0

Add ASDF to your shell configuration.

Bash

echo '. "$HOME/.asdf/asdf.sh"' >> ~/.bashrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.bashrc
source ~/.bashrc

ZSH

echo '. "$HOME/.asdf/asdf.sh"' >> ~/.zshrc
echo '. "$HOME/.asdf/completions/asdf.bash"' >> ~/.zshrc
source ~/.zshrc

Verify installation:

asdf --version

Add the PHP Plugin

Install the PHP plugin for ASDF:

asdf plugin add php https://github.com/asdf-community/asdf-php.git

Install PHP 8.5

List available PHP versions:

asdf list all php

Install PHP 8.5:

asdf install php 8.5.0

Set PHP 8.5 as the global default:

asdf global php 8.5.0

Reload your shell:

exec $SHELL

Verify the installation:

php -v

Expected output:

PHP 8.5.x (cli)

Useful ASDF Commands

List installed PHP versions:

asdf list php

Install another PHP version:

asdf install php 8.4.0

Switch globally:

asdf global php 8.4.0

Switch locally for a project:

asdf local php 8.5.0

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

Verify:

composer --version