PHP

To get latest versions of PHP

Ubuntu
sudo add-apt-repository ppa:ondrej/php
sudo apt update
Debian
sudo apt-get update
sudo apt-get -y install lsb-release ca-certificates curl
sudo curl -sSL -o /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt-get update

Install latest PHP version.

sudo apt -y install php8.3-fpm

Add PHP extension

sudo apt install -y php8.3-mbstring php8.3-mysql php8.3-common php8.3-mysql php8.3-xml php8.3-curl php8.3-gd php8.3-imagick php8.3-cli php8.3-dev php8.3-imap php8.3-mbstring php8.3-opcache php8.3-soap php8.3-zip php8.3-intl php8.3-bz2

Switch PHP

sudo update-alternatives --config php

Composer

Use command line instructions of Composer website to download and install latest version of Composer

composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"

You have just to copy installation instructions and composer will be download, this is an example:

sudo mv composer.phar /usr/local/bin/composer
sudo chown -R $USER ~/.config/composer/

To install global package like laravel

composer global require laravel/installer

Add this to .zshrc

vim ~/.zshrc
~/.zshrc
export PATH=~/.config/composer/vendor/bin:$PATH
source ~/.zshrc

Now you can use composer.

Table of Contents