Laravel 12 Installation Guide: Zero to Production in Minutes

Laravel 12 will simplify its installation process when it releases in Q1 2025. Developers can deploy their applications from scratch to production within minutes. The new version comes packed with powerful features like asynchronous caching and smooth integration with modern tools such as Tailwind CSS 4.0 and Vite 6.0.

Your system needs PHP 8.2 or higher to utilize the framework's modern capabilities and improved performance features. This piece walks you through the complete installation process with Laravel installer and Composer. You'll learn to set up your development environment, configure your application and run health checks to build strong applications with Laravel's latest version.

Laravel 12

Setting Up Your Development Environment

A resilient development environment is the foundation for building Laravel 12 applications. You'll need to set up everything in a smooth development workflow.

Installing PHP 8.2+ and Required Extensions

PHP 8.2 is the minimum requirement for Laravel 12. The core PHP extensions needed for optimal performance include:

Package managers help you install these extensions on your operating system. Unix-based systems need this command:

sudoapt-getinstallphp8.2 php8.2-cli php8.2-common php8.2-fpm php8.2-mysql php8.2-zip php8.2-gd php8.2-mbstring php8.2-curl php8.2-xml php8.2-bcmath openssl php8.2-json php8.2-tokenizer

Configuring Composer for Laravel Installer

The latest version of Composer should be installed on your system. You can update Composer with:

composerself-update

The Laravel installer needs to be installed globally through Composer:

composerglobal require laravel/installer

Your terminal session needs a restart to make the Laravel installer work correctly.

Setting Up Local Database Server

Laravel 12 works well with these database systems:

SQLite serves as Laravel's default development database. MySQL or PostgreSQL users need to modify their .env file's database configuration. MySQL setup requires:

  1. A new database created with your preferred database management tool
  2. These environment variables configured:
    • DB_CONNECTION=mysql
    • DB_HOST=127.0.0.1
    • DB_PORT=3306
    • DB_DATABASE=your_database_name
    • DB_USERNAME=root
    • DB_PASSWORD=your_password

SQLite users can create their database file with:

touchdatabase/database.sqlite

The .env file needs updating with your SQLite database's absolute path.


Installing Laravel 12 Using Composer

Composer makes it easy to install Laravel 12 on your system. Make sure your development environment meets all prerequisites before starting the installation.

Running Laravel Installation Command

Start by getting the latest version of Composer with this command:

composerself-update

The next step creates a new Laravel 12 project using this command:

composercreate-project --prefer-dist laravel/laravel your-project-name"12.x-dev"

Use your desired project name instead of "your-project-name". Composer will download all dependencies, including core framework files and essential packages.

You might see a "directory not empty" error. Run ls -lah to spot hidden files blocking the installation. Either remove existing files or pick a different directory.


Installing Laravel 12 in a Different Way

Laravel 12 hasn't been officially released yet, but you can use the --dev flag with the Laravel installer to fetch the latest code from the laravel/laravel repository's main branch, ensuring you always have the most up-to-date version.

laravel new your-project-name --dev

If you encounter a "directory not empty" error, check hidden files with:

ls -lah

Either remove existing files or choose a different directory.

Verifying Installation Success

The setup needs verification through these steps:

  1. Go to your project directory:

    cdyour-project-name
  2. Install and build frontend dependencies:

    npminstall&&npmrun build
  3. Start the development server:

    composerrun dev

A successful installation lets you access your application at http://localhost:8000 in your web browser. Laravel's welcome page shows that everything works correctly.

Make sure to check these components:

Laravel keeps track of exceptions and failures in logs. Any issues you face can be diagnosed through detailed error messages in the storage/logs directory.


Configuring Your New Laravel Application

The right configuration will optimize your Laravel 12 application's performance. Your application needs specific settings configured after installation to prepare it for development.

Setting Environment Variables

The .env file in your application's root directory controls significant configuration settings. You should copy the .env.example file to create your .env file:

cp.env.example .env

The next step generates a unique application key:

php artisan key:generate

Your application's security improves when you avoid committing the .env file to source control. You should maintain separate environment files for different scenarios:

Database Connection Setup

Laravel's database configuration lives in config/database.php. You need to update these variables in .env to configure your database connection:

DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database DB_USERNAME=root DB_PASSWORD=your_password

Laravel supports database URLs for managed services. To name just one example:

DB_URL=mysql://root:password@127.0.0.1/database?charset=UTF-8

Cache and Session Configuration

The right cache configuration optimizes your application's performance. Update the cache driver in .env:

CACHE_DRIVER=file

Your production environments need these commands to boost performance:

php artisan config:cachephp artisan route:cache php artisan view:cache php artisan event:cache

The session configuration lives in config/session.php. The vital session settings include:

During development, clear cached configurations with:

php artisan optimize:clear

Note that you should run php artisan config:cache after changing environment variables in production. This command combines all configuration options into a single file and improves load times by a lot.


Testing Your Installation

You need to verify that your Laravel 12 setup works correctly after installation and configuration. Let's get into the simple testing steps you should follow.

Running Built-in Development Server

The command to start Laravel's local development server is:

php artisan serve

The server starts on port 8000 by default. You can specify a different port if 8000 is already in use:

php artisan serve --port=9000

Accessing the Welcome Page

Your application becomes available at:

A welcome page shows up with a vibrant background, clean icons and both light and dark themes. This page tells you that your installation worked properly.

The command to check your exact version is:

php artisan --version

When you see "Laravel Framework 12.0.0", it means your installation succeeded.

Basic Health Checks

Laravel 12 comes with a built-in health check system you can access through the /up endpoint. These checks are a great way to get:

The health check gives you:

You can customize the health check URI in bootstrap/app.php:

->withRouting(web:__DIR__.'/../routes/web.php',commands:__DIR__.'/../routes/console.php',health:'/status')

The framework triggers a DiagnosingHealth event during health checks. This lets you add more checks for:

You should think about adding custom health checks that verify your application's vital components.


Conclusion

Laravel 12 delivers the most important upgrades with its efficient installation process and reliable feature set. This piece guides you through everything you need to know - from PHP 8.2+ setup with required extensions to development environment configuration and application testing.

Composer integration and the Laravel installer have made the installation process quick and simple. By doing this, your Laravel 12 application will be ready with:

The success of Laravel development relies heavily on proper environment variables and database settings. Your application's health can be monitored easily through the /up endpoint.

This solid foundation enables you to build powerful web applications. Laravel 12's modern features include asynchronous caching and smooth integration with tools like Tailwind CSS 4.0 and Vite 6.0. Start learning these capabilities now and see your applications transform.


FAQs

Laravel 12 requires PHP 8.2 or higher, along with essential PHP extensions like Ctype, cURL, DOM, Fileinfo, JSON, Mbstring, OpenSSL, PCRE, PDO, Tokenizer, and XML. You'll also need Composer for package management and a supported database system such as MySQL, PostgreSQL, or SQLite.

To install Laravel 12, use the Composer command: composer create-project --prefer-dist laravel/laravel your-project-name "12.x-dev". Replace "your-project-name" with your desired project name. This command downloads all necessary dependencies and core framework files.

After installation, navigate to your project directory, install frontend dependencies with npm install && npm run build, and start the development server using composer run dev. Then, configure your environment variables in the .env file, set up your database connection, and generate an application key with php artisan key:generate.

You can verify your installation by accessing http://localhost:8000 in your web browser. If you see the Laravel welcome page, it indicates a successful setup. Additionally, you can run php artisan --version in your terminal to confirm the exact version of Laravel installed.

Laravel 12 introduces a built-in health check system accessible via the /up endpoint. This feature allows for monitoring application status, reporting to uptime monitors, and communicating with load balancers. You can customize the health check URI and implement additional checks for database connectivity, cache status, and external service dependencies.
Previous: Laravel Telescope: A Powerful Debugging Tool for Your Laravel AppNext: Fetch API vs. Axios: A Comprehensive Comparison for Making HTTP Requests

Share