Laravel is a powerful PHP framework that makes building complex web applications a breeze. In this guide, you’ll learn how to install and configure Laravel and get your first Laravel project running on your computer.
Before we start, make sure you have:
You will have to follow the steps given below for installing Laravel onto your system −
Laravel uses a dependency manager called Composer to install all the required libraries.
Visit the following URL and download Composer:
👉 https://getcomposer.org/download/
Follow the installation instructions provided on the website. It’s well-documented and straightforward.
After installing Composer, verify the installation by running the following command in your terminal or command prompt:
composer
If you see an output similar to this (a list of Composer commands and options), Composer has been installed successfully:
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 2.7.2 2024-03-11 17:12:18
Usage:
command [options] [arguments]
– Now we’re ready to move on to installing Laravel!
Now that Composer is ready, let’s install Laravel globally so you can use the laravel
command from anywhere on your system.
Run the following command in your terminal:
composer global require laravel/installer
– This will install the Laravel installer globally.
Once the Laravel installer is ready, you can create a new Laravel project with this command:
laravel new project-name
Replace project-name
with the name you want for your project.
For example:
laravel new myapp
This command will create a new Laravel application in a folder called myapp
.
There are multiple ways to create a new Laravel project using Composer. Here are the two most common methods:
If you’ve already created and navigated into your desired project directory, you can run:
composer create-project laravel/laravel --prefer-dist
– This will install Laravel into the current directory.
You can skip manually creating a folder and let Composer create the project directory for you. Simply run:
composer create-project --prefer-dist laravel/laravel myapp
This will:
– Tip: Replace myapp
with your preferred project name.
Navigate to your project directory:
cd myapp
Then, start the built-in Laravel development server:
php artisan serve
You should see something like:
Starting Laravel development server: http://127.0.0.1:8000
Now open http://127.0.0.1:8000
in your browser, and you’ll see the Laravel welcome page! 🎉
You’ve successfully installed and configured Laravel, and your first Laravel project is running.