How to Install Laravel 12

How to Install Laravel 12

 How to Install Laravel 12

Laravel is one of the most popular PHP frameworks for building web applications. With the release of Laravel 12, developers get improved performance, better security, and new features. In this guide, we’ll show you how to install Laravel 12 on your system step by step.

Prerequisites

Before installing Laravel 12, make sure your system meets the following requirements:

  • PHP 8.2 or higher
  • Composer (PHP dependency manager)
  • Database (MySQL, PostgreSQL, SQLite, or SQL Server)
  • Web Server (Apache, Nginx, or Laravel’s built-in server)

If you haven’t installed PHP or Composer yet, follow these steps:

Installing PHP and Composer

  1. Install PHP:

    • Windows: Download PHP from windows.php.net or use XAMPP.
    • macOS: Use Homebrew:
      brew install php
    • Linux (Debian/Ubuntu):
      sudo apt update && sudo apt install php-cli unzip
  2. Install Composer:

    • Download Composer from getcomposer.org.
    • Verify installation by running:
      composer --version

Step 1: Install Laravel Installer

Open a terminal and run the following command to install Laravel globally via Composer:

composer global require laravel/installer

Make sure the global Composer bin directory is in your system’s PATH.

  • Windows: Add C:\Users\YourUser\AppData\Roaming\Composer\vendor\bin to system variables.
  • macOS/Linux: Add this to your ~/.bashrc or ~/.zshrc file:
    export PATH="$HOME/.composer/vendor/bin:$PATH"

Step 2: Create a New Laravel 12 Project

Now, you can create a new Laravel project using:

laravel new project-name

Alternatively, if you don’t want to install the Laravel installer, you can use Composer directly:

composer create-project --prefer-dist laravel/laravel project-name

Replace project-name with your desired project folder name.

Step 3: Navigate to Your Project Directory

cd project-name

Step 4: Start the Laravel Development Server

Run the following command to start the built-in development server:

php artisan serve

By default, Laravel will be available at:
👉 http://127.0.0.1:8000

Step 5: Configure Environment Variables

Laravel stores environment settings in the .env file. You may need to configure your database connection here:

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database_name DB_USERNAME=your_database_user DB_PASSWORD=your_database_password

After updating the .env file, run:

php artisan config:clear php artisan migrate

Conclusion

You have successfully installed Laravel 12! 🎉 Now, you can start building your Laravel application. Happy coding!

Souy Soeng

Souy Soeng

Our website teaches and reads PHP, Framework Laravel, and how to download Admin template sample source code free. Thank you for being so supportive!

Github

Post a Comment

CAN FEEDBACK
close