Introduction
There has been a recent update to the Installation section for the Laravel documentation which makes it even easier to setup all the software required to run and work with Laravel apps.
Setup
The following applications get installed through this setup.
- PHP + PHP Extensions
- Composer
- Laravel installer
It’s a one-line command that’s run in the terminal, there are three versions each for one of the major operating systems which are Windows, MacOS, and Linux.
Windows
Open the PowerShell terminal application and run the following command.
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows'))
MacOS
Open the terminal app and run the bash command to run the install script.
/bin/bash -c "$(curl -fsSL https://php.new/install/mac)"
Linux
Open the terminal app to start the setup.
Make sure the curl tool is installed. If not, use your package manager to install it. The below command uses APT, the package manager for Ubuntu.
# Ubuntu install using APT
# Use the current package manager for your distribution of Linux
sudo apt install -y curl
Run the below command using the curl command.
/bin/bash -c "$(curl -fsSL https://php.new/install/linux)"
Post install
After running the command corresponding to your operating system then close and re-open your terminal app.
Check that PHP and composer are working.
Use the below version check to see if PHP is set up and working.
php -v
For composer just use the composer command to see if the usage information is output.
composer
Now create a Laravel app using the installer.
laravel new sample-app
These are the options I selected to create the project.
- Would you like to install a starter kit?
- No starter kit
- Which testing framework do you prefer?
- Pest
- Which database will your application use?
- SQLite
- Would you like to run the default database migrations?
- Yes
After the installer has completed now change the current directory into the project.
cd sample-app
And start up the app.
php artisan serve
Open the browser, add http://127.0.0.1:8000 into the URL bar and press Enter to load up the app.