🚀 Laravel 12 Installation Guide: Step-by-Step for Beginners

Laravel 12 is the latest and most powerful version of the popular PHP framework known for its elegant syntax, developer-friendly features, and robust performance. In this tutorial, we will guide you through a step-by-step Laravel 12 installation process on your local machine or server.


🛠️ Prerequisites

Before you begin, make sure your system meets the following requirements:

✅ Server Requirements

  • PHP 8.2 or higher
  • Composer (latest version)
  • PHP Extensions:

    • BCMath
    • Ctype
    • Fileinfo
    • JSON
    • Mbstring
    • OpenSSL
    • PDO
    • Tokenizer
    • XML
    • Curl
You can verify your PHP version by running:
php -v
To check if Composer is installed:
composer -V

📥 Step 1: Install Laravel 12 Using Composer

Open your terminal and run the following command:

composer create-project laravel/laravel my-laravel-app

  • my-laravel-app is your project directory name. You can change it as per your project.
  • This command will download Laravel 12 and all its dependencies.

Laravel 12 requires Composer 2.0 or later.


📁 Step 2: Move Into Your Project Directory

cd my-laravel-app

⚙️ Step 3: Set File Permissions (Linux/macOS)

Make sure the storage/ and bootstrap/cache/ directories are writable:

chmod -R 775 storage chmod -R 775 bootstrap/cache

🧪 Step 4: Run Laravel Development Server

Laravel comes with a built-in development server. You can start it with:

php artisan serve

This will start the server at:

http://127.0.0.1:8000

Open this URL in your browser to see your new Laravel 12 project in action!


⚡ Step 5: Configure Environment File

Laravel uses .env file to manage environment-specific settings like database credentials.

Make sure to create and configure your .env file:

cp .env.example .env php artisan key:generate

Edit your .env file to set database and mail configuration:

DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_db_name DB_USERNAME=your_db_user DB_PASSWORD=your_db_password

💾 Step 6: Set Up Database (Optional but Recommended)

To use Laravel with MySQL:

  1. Create a new database in MySQL.
  2. Configure .env file as shown above.
  3. Run migrations:
php artisan migrate

🌐 Optional: Set Virtual Host (Apache)

If you prefer accessing Laravel via a custom domain like http://laravel.test, set up a virtual host:

Example Apache Vhost:

<VirtualHost *:80> ServerName laravel.test DocumentRoot "/path/to/my-laravel-app/public" <Directory "/path/to/my-laravel-app/public"> AllowOverride All Require all granted </Directory> </VirtualHost>

Add entry in hosts file:

sudo nano /etc/hosts

Add this line:

127.0.0.1 laravel.test

Then restart Apache:

sudo service apache2 restart

🧩 Optional: Install Laravel Breeze (Starter Kit)

To quickly scaffold authentication:

composer require laravel/breeze --dev php artisan breeze:install npm install && npm run dev php artisan migrate

✅ Laravel 12 Installation Complete!

You’re now ready to start building amazing web applications with Laravel 12!


📝 Final Checklist

    
Task                   Status
Composer Installed                 
Laravel 12 Created                 
.env Configured                 
Database Connected                 
Dev Server Working                 
Optional Features Installed                 🚫/✅

📚 Useful Commands

    
Command        Description             
php artisan serve Start development server
php artisan migrate Run database migrations
php artisan make:model Create new Eloquent model
php artisan make:controller Create a new controller
php artisan route:list View registered routes

🤔 FAQs

❓ Is Laravel 12 stable?

Yes, Laravel 12 is the latest stable release with cutting-edge features and improvements.

❓ Can I upgrade from Laravel 11 to 12?

Yes, but it's recommended to follow the official upgrade guide to avoid breaking changes.

❓ Do I need Node.js?

Only if you're using Laravel Mix, Breeze, or building a frontend with Vue/React.


Post a Comment

Previous Post Next Post

Contact Form