To install PHP and the Laravel installer with a single command, we need to take advantage of package managers that can streamline this process and ensure it’s been running smoothly to the very end even in the end when we check to confirm them. For Linux-based systems (such as Ubuntu) or macOS, Homebrew or APT can simplify the installation of both PHP and Laravel that we have shown in this guide below:
Here is a guide to install PHP and the Laravel installer in a single command
 For Linux (Ubuntu) Users
(I) Update System Packages
Before starting, ensure your system is up to date
sudo apt update && sudo apt upgrade -y
(III) Install PHP & Laravel Using Composer
You can install PHP, Composer (a PHP dependency manager), and the Laravel installer in one command. Run the following command
sudo apt install php-cli composer -y && composer global require laravel/installer
-  `php-cli` installs PHP’s command-line interface
- `composer` installs the Composer dependency manager
- Â `composer global require laravel/installer` installs the Laravel installer globally, so it can be accessed from anywhere in the system
(III) Add Composer to Your Path
To make sure the Laravel command is globally accessible, add Composer’s global `bin` directory to your system’s PATH. Edit the `.bashrc` or `.zshrc` file and add the following line
export PATH="$HOME/.config/composer/vendor/bin$PATH"
After editing, run
source ~/.bashrc
Now you should be able to run the `laravel` command anywhere in your terminal.
For macOS Users (Using Homebrew)
(I) Install Homebrew
If you do not have Homebrew installed, run
/bin/bash -c "$(curl -fsSL https//raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(II) Install PHP and Composer
Homebrew allows you to install PHP and Composer quickly with a single command
brew install php composer && composer global require laravel/installer
- `brew install php` installs PHP via Homebrew.
- `brew install composer` installs Composer.
- The Laravel installer is then globally installed using Composer.
III Add Composer to Your Path
Similar to Linux, you need to make the Laravel command globally accessible
export PATH="$HOME/.composer/vendor/bin$PATH"
Afterward, reload the terminal by running
source ~/.zshrc
The Laravel installer should now be available globally.
Verification
To verify that PHP and the Laravel installer are installed correctly, you can use the following commands
php -v
This will display the PHP version installed.
laravel --version
This will display the Laravel installer version and for both Linux and macOS, you have streamlined the process by using package managers to install PHP, Composer, and Laravel. With these commands, you have installed PHP and the Laravel installer in a single step, simplifying the setup process for your development environment.












