Laravel 12 is the latest evolution of the world’s most popular PHP framework, offering a streamlined developer experience, robust features, and a thriving ecosystem. Whether you’re building a simple website or a complex web application, starting with a clean, correct installation is crucial for productivity and long-term success.
If you’re new to Laravel or PHP frameworks, the installation process might seem intimidating. But with the right steps and a little guidance, you’ll have your Laravel 12 project up and running in minutes. This comprehensive guide covers every detail, from system requirements to troubleshooting, so you can focus on building, not debugging.
Let’s get started with the Laravel 12 installation step by step.
Pro tip: Laravel 12 introduces new features and updated requirements. If you’re upgrading from an earlier version, check the official upgrade guide for compatibility notes.
Why Choose Laravel 12?
Laravel remains the framework of choice for modern PHP development in 2026, thanks to its expressive syntax, built-in security, and active community. Laravel 12 brings performance improvements, enhanced developer tools, and better support for PHP 8.2+.
- Modern PHP support: Fully compatible with PHP 8.2 and above, leveraging the latest language features.
- Robust ecosystem: Includes Laravel Breeze, Jetstream, and Sail for rapid scaffolding and local development.
- Security by default: Out-of-the-box CSRF protection, authentication scaffolding, and secure session management.
- Easy testing and debugging: Built-in PHPUnit integration and improved error handling.
- Scalable architecture: Supports microservices, REST APIs, and monolithic applications.
Whether you’re building a SaaS, an e-commerce platform, or a blog, Laravel 12 provides the foundation you need.
Prerequisites for Laravel 12 Installation
Before you install Laravel 12, make sure your development environment meets the minimum requirements. This ensures a smooth installation and prevents common errors.
- PHP: 8.2 or higher (with required extensions: OpenSSL, PDO, Mbstring, Tokenizer, XML, Ctype, JSON, BCMath, Fileinfo)
- Composer: Latest stable version (download here)
- Database: MySQL 8+, PostgreSQL, SQLite, or SQL Server
- Web server: Apache, Nginx, or Laravel’s built-in development server
- Node.js & npm: (Optional, for compiling frontend assets with Vite or Laravel Mix)
To check your PHP version, run:
php -vTo check Composer, run:
composer --versionIf you’re missing any requirements, install or update them before proceeding. On Windows, tools like XAMPP or Laragon simplify setup. On macOS, Homebrew is recommended. On Linux, use your distribution’s package manager.
Further reading: For a detailed checklist, see our SEO for New Website Checklist (many tips apply to new Laravel projects too).
Step 1: Install Composer

Composer is the PHP dependency manager that powers Laravel. If you haven’t installed Composer yet, download it from getcomposer.org and follow the instructions for your operating system.
- Windows: Use the Composer installer for a guided setup.
- macOS/Linux: Run the following in your terminal:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php composer-setup.php php -r "unlink('composer-setup.php');" sudo mv composer.phar /usr/local/bin/composerVerify installation:
composer --versionIf you see the version number, you’re ready to proceed.
Step 2: Create a New Laravel 12 Project

With Composer installed, you can create a new Laravel 12 project in any directory. Open your terminal and run:
composer create-project laravel/laravel my-app "12.*" --prefer-dist
Replace my-app with your desired project name. Composer will download Laravel 12 and all its dependencies, setting up a ready-to-use application structure.
Once complete, navigate into your project folder:
cd my-appYou’ll see the standard Laravel directory structure:
- app/
- bootstrap/
- config/
- database/
- public/
- resources/
- routes/
- storage/
- tests/
- vendor/
This structure is designed for scalability and maintainability.
Tip: For advanced project scaffolding, consider Laravel Jetstream or Breeze. See the official docs for details.
Step 3: Configure Environment Variables

Laravel uses an .env file to manage environment-specific settings like database credentials and app keys. After installation, you’ll find a .env.example file in your project root.
- Copy
.env.exampleto.env:
cp .env.example .env- Generate a unique application key:
php artisan key:generateThis command sets the APP_KEY in your .env file, which is critical for session and encryption security.
Open .env in your editor and review the settings. You’ll need to update the database section next.
Step 4: Set Up Your Database

Laravel supports MySQL, PostgreSQL, SQLite, and SQL Server. For local development, MySQL or SQLite are most common.
Update your .env file with your database credentials:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel12 DB_USERNAME=root DB_PASSWORD=Create the database in your DBMS (for MySQL):
CREATE DATABASE laravel12;Save your changes. Laravel will use these settings for migrations and queries.
Further reading: Learn more about database setup in our Flutter project creation guide (many concepts overlap for backend APIs).
Step 5: Run Database Migrations
Laravel migrations create and manage your database schema. To set up the default tables (users, password resets, etc.), run:
php artisan migrateIf successful, you’ll see “Migration table created successfully.” Check your database to confirm the new tables.
If you encounter errors, double-check your .env settings and ensure your database server is running.
Step 6: Install Frontend Dependencies (Optional)

If you plan to use Laravel’s frontend tooling (Vite, Mix, or npm scripts), install Node.js and npm. Then, from your project root, run:
npm install npm run devThis compiles your CSS and JavaScript assets for development. For most backend APIs or simple apps, this step is optional.
Step 7: Start the Development Server

Laravel includes a built-in development server for quick testing. Start it with:
php artisan serveBy default, your app is available at http://localhost:8000. Open this URL in your browser to see the Laravel welcome page, confirming your installation is complete.
Tip: For production, deploy to Apache, Nginx, or a cloud platform. See the official deployment guide for best practices.
Troubleshooting Common Installation Issues
Even with careful setup, you might encounter errors. Here’s how to resolve the most common Laravel 12 installation problems:
- Composer Memory Limit Errors: Increase PHP’s memory limit or run
COMPOSER_MEMORY_LIMIT=-1 composer create-project ... - Missing PHP Extensions: Install required extensions (e.g.,
sudo apt install php-mbstring php-xmlon Ubuntu) - Database Connection Refused: Check
.envcredentials, ensure the DB server is running, and verify network settings - Permission Issues: Set correct permissions for
storage/andbootstrap/cache/directories (chmod -R 775 storage bootstrap/cache) - Port Already in Use: Specify a different port (
php artisan serve --port=8080)
For more help, consult the Laracasts discussion forums or Laravel’s GitHub issues.
Next Steps After Installation
With Laravel 12 installed, you’re ready to start building! Here are some recommended next steps:
- Explore the directory structure: Understand where controllers, models, views, and routes live
- Set up authentication: Use Laravel Breeze or Jetstream for quick user login scaffolding
- Configure version control: Initialize a Git repository and push to GitHub or GitLab
- Install helpful packages: Try Sanctum for API authentication or Cashier for subscriptions
- Read the docs: The official Laravel 12 documentation is comprehensive and beginner-friendly
Related: For SEO best practices on your new Laravel site, see our guide to SEO Onpage vs Offpage Optimization.
Laravel 12 Installation on Shared Hosting or Cloud
While local development is recommended, you may want to install Laravel 12 on a shared host or cloud server:
- Shared hosting: Upload your project via FTP/SFTP, set
public/as the web root, and ensure PHP 8.2+ is available - Cloud (VPS): SSH into your server, install PHP, Composer, and Git, then clone your repository and run
composer install - Managed Laravel hosts: Platforms like Laravel Forge or Ploi automate deployment and SSL setup
Always update your .env for production and set correct permissions. For more on hosting, see our Best WordPress Hosting Providers guide (many tips apply to Laravel too).
Frequently Asked Questions
Can I install Laravel 12 globally?
Laravel recommends using Composer’s create-project command for each new project. However, you can install the Laravel installer globally with composer global require laravel/installer and then run laravel new project-name.
How do I upgrade from Laravel 11 to 12?
Follow the official upgrade guide. Update your composer.json to require laravel/framework ^12.0, run composer update, and address any breaking changes.
What is Laravel Sail?
Laravel Sail is a Docker-based local development environment. Install it with composer require laravel/sail --dev and start with ./vendor/bin/sail up. It’s ideal for consistent team setups.
How do I deploy Laravel 12 to production?
Deploy to a server with PHP 8.2+, set up your database, configure .env, run composer install --optimize-autoloader --no-dev, and set correct permissions. Use php artisan config:cache and php artisan route:cache for performance.
Installing Laravel 12 is straightforward when you follow each step carefully. By ensuring your environment meets the requirements, using Composer to set up your project, and configuring your database and environment variables, you’ll have a powerful PHP framework ready for any web application.
With your Laravel 12 app running, you’re set to explore the framework’s features, build robust APIs, and deliver modern web experiences. For more Laravel tips, troubleshooting, and advanced guides, bookmark the official documentation and join the Laravel community forums.
Happy coding!
