Articles

Install Laravel with Composer and Laravel installer

Install Laravel with composer

To Install Laravel, we’ll use Composer and Laravel installer. The main reason we use this method is that it provides a step-by-step wizard that will discuss it in detail.

Before starting, you must know that Laravel requires PHP, Node, and npm. If you don’t have them, You can use these articles:

Alright, Let’s try Laravel.

 

Preparing Composer

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on, and it will manage them for you.

We have an article to install it based on your machine. You can use it: Install Composer: Step-by-Step for All Platforms

By running the below command, you must see the version if it’s installed in your system:

composer
Install Composer

Install Composer

Setting up Laravel Installer

First, let’s install Laravel Installer globally to use it in each project. Use this command in Terminal or cmd.

composer global require laravel/installer
Laravel installer

Laravel installer

 

Then we should add composer bin path to make laravel command executable. First use the below command to find composer bin path:

composer global config bin-dir --absolute
compser global path

Finding global composer bin path

For example here, our composer bin path is: /Users/hadishb/.composer/vendor/bin. To make it dynamic, we can replace our user path with $HOME, just like this: $HOME/.composer/vendor/bin

Based on your operation system, Do like this:

macOS/Linux

In Terminal if you use:

  • zsh, run command :
    nano ~/.zshrc
  • bash, run command :
    nano ~/.bash_profile For Mac,  nano ~/.bashrc For Linux

Then add this inside editor (replace “$HOME/.composer/vendor/bin” with your composer bin path if was different) :

export PATH=”$HOME/.composer/vendor/bin:$PATH”

Adding Composer bin Path

Adding Composer bin Path

Use control + x then Y and finally Enter to save it. Now run for :

  • zsh :
    source ~/.zshrc
  • bash :
    For Mac: source ~/.bash_profile | For Linux: source ~/.bashrc

That’s it. With runinng laravel command you must see Laravel Installer version:

Laravel installer

Laravel installer

Windows

To add composer bin folder path:

  1. Go to Control Panel->System ->Advanced system settings and then Environment Variables.
  2. Click on “Edit the system environment variables”.
  3. In the “User variables” section (top), find the variable called Path and click Edit.
  4. In the new window, click New and paste this path: %USERPROFILE%\AppData\Roaming\Composer\vendor\bin
  5. Click OK, then again OK on all other windows to save.
  6. Now close and reopen your Command Prompt or PowerShell
  7. Try this to check if Laravel is ready:
    laravel --version

Installing Laravel

Now we can create any Laravel project. For example, suppose project name is first-app, use the below command to create the project and it’s folders

laravel new first-app

Based on laravel version, you face different installation wizards. Here we will discuss about Laravel 12.x installation wizard. Let’s get started.

Step 1: Which starter kit would you like to install?

Starter Kit Laravel

Starter Kits Laravel

The starter kit will create built-in features that make your laravel application level up such as routes, controllers, and views you need to register and authenticate your application’s users.

React

React starter kit gives us a modern starting point for building Laravel applications with a React frontend using Inertia. This kit utilizes React 19, TypeScript, Tailwind, and the shadcn/ui component library.

Vue

Vue starter kit builds Laravel applications with a Vue frontend using Inertia. This kit utilizes the Vue Composition API, TypeScript, Tailwind, and the shadcn-vue component library.

Livewire

Livewire starter kit provides the perfect starting point for building Laravel applications with a Laravel Livewire frontend. This kit utilizes Livewire, Tailwind, and the Flux UI component library.

None

If you want to create your laravel application from scratch and do not need any built-in options, you must select this.

 

Step 2: Which authentication provider do you prefer?

Laravel Authentication Provider

Laravel Authentication Provider

When you select the starter kit in the first step, you must select which authentication provider you need to be installed. We have 2 options:

Laravel’s built-in authentication

If you want to have basic features such as an authentication system to login, registration, password reset, email verification, and more,  use this option.

WorkOS (Requires WorkOS account) 

If you want to have built-in authentications plus options like :

  • Social authentication (Google, Microsoft, GitHub, and Apple)
  • Passkey authentication
  • Email-based “Magic Auth”
  • SSO

use this option but it requires a WorkOS account.

 

Step 3: Which testing framework do you prefer?

Laravel Testing Frameworks

Laravel Testing Frameworks

In this step, you must select a testing framework that can be Pest or PHPUnit. We have a full article about writing php unit tests. You can check it: Learn How to Test Code With PHPUnit

After selecting your testing framework,it will download and install laravel requirement files.

 

Step 4: Database Connection/Installing NPM

Laravel Database Connections

Laravel Database Connections

As default, Laravel installer will use SQLite as your database. If you select “None” for Starter Kit in first step, you can choose other database connections like:

  • MariaDB
  • MySQL
  • PostgreSQL
  • SQLite
  • SQL Server

 

After connecting successfully to database, it will migrate tables on it. Now need to hit YES to install NPM requirements.

NPM install in Laravel

NPM install in Laravel

Step 5: Launch Laravel

Laravel Installed Successfully

Laravel Installed Successfully

Great! Now need to start laravel to be live. Inside Terminal/Cmd, Navigate to the project folder (cd first-app) and run:

composer run dev
Launching Laravel

Launching Laravel

As you see above,Our Laravel project is running on http://127.0.0.1:8000

Let’s test it:

Laravel live on localhost

Congratulations! We have done succesfully.

How to Install PHP on macOS: Intel Chip and Apple Silicon(M1/M2/M3)
Laravel Authorization: Gate and Policy Ultimate Guides
Leave a Reply

Your email address will not be published. Required fields are marked *

Shopping cart
Sign in

No account yet?

Create an Account