How Do I Start a New Laravel Project?
This guide explains step by step how to start a Laravel project, including installing PHP, Composer, and creating the app on Linux, macOS and Windows.
If you want to start a Laravel project, you need a few essential tools installed: PHP, Composer and a local web server. Below are the detailed steps for Windows, Linux and macOS.
1. Checking and installing PHP
Laravel requires PHP 8 or higher.
Linux (Ubuntu/Debian)
sudo apt update
sudo apt install php php-cli php-mbstring php-xml php-bcmath php-curl php-zip unzip curl
php -v
macOS (using Homebrew)
brew update
brew install php
php -v
Windows
- Download official PHP.
- Add PHP to the
PATHenvironment variable. - Check in Command Prompt:
php -v
2. Installing Composer
Composer is the PHP package manager used by Laravel.
Linux/macOS
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer -V
Windows
- Download Composer-Setup.exe and follow the instructions.
- Check in Command Prompt:
composer -V
3. Installing the Laravel Installer
You can use either the Laravel Installer or Composer's Create-Project.
Global Laravel Installer
composer global require laravel/installer
# Make sure ~/.composer/vendor/bin (Linux/macOS) or %USERPROFILE%\AppData\Roaming\Composer\vendor\bin (Windows) is in PATH
laravel -V
4. Creating a new project
Using the Laravel Installer
laravel new project-name
Using Composer Create-Project
composer create-project laravel/laravel project-name
This creates a project-name folder with the full Laravel structure.
5. Starting the local server
In the project directory:
cd project-name
php artisan serve
Then open http://127.0.0.1:8000 in your browser.
6. Additional configuration
- Check the
.envfile for the database settings. - Make sure you have the required PHP extensions installed.
- You can use Laravel Valet (macOS) or Laravel Homestead for more complex environments.
You now have a working Laravel project and can start building your application.