Laravel 12 is the latest version of the most popular PHP framework, widely used for creating robust, scalable web applications with ease. This guide walks you through a simple yet professional step-by-step process for installing and setting up Laravel 12.
Laravel 12 Installation Setup: Step by Step
- PHP (version 8.2 or higher)
- Composer installed
- A local development environment (XAMPP, WAMP, Laragon, or Docker)
Step 1: Verify PHP and Composer
Check PHP version:
php -v
Verify Composer installation:
composer --version
Step 2: Install Laravel 12
Use Composer to create a new Laravel 12 project:
composer create-project laravel/laravel:^12.0 my-laravel12-app
Navigate to your new project:
cd my-laravel12-app
Step 3: Run Your Laravel Application
Serve your Laravel application:
php artisan serve
Open your browser and visit:
http://localhost:8000
Step 4: Setting Up Database (Optional)
Edit your .env file to configure your database connection:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_username
DB_PASSWORD=your_password
Run migrations:
php artisan migrate
Step 5: Laravel Breeze (Authentication Setup - Optional)
Quickly set up authentication with Laravel Breeze:
composer require laravel/breeze --dev
php artisan breeze:install
npm install
npm run build
php artisan migrate
Conclusion
Congratulations! You've successfully installed and set up Laravel 12. You're now ready to explore and build powerful web applications.
Configuring the Environment That Every Project Shares
After installation, spend ten minutes on .env before writing any code. Set APP_NAME, switch APP_URL to the address you actually use locally, and point the database block at a database you've created — Laravel won't create it for you, and the first migration error most beginners see is just a missing database. Run php artisan key:generate if the installer didn't, because sessions and encrypted cookies silently depend on it. Finally set your cache and queue drivers to database for local work: it keeps behavior consistent with production without requiring Redis on your laptop.
Your First Five Minutes of Real Code
Prove the install works end to end before building anything: define a route in routes/web.php that returns a view, create the Blade file, and load it in the browser. Then run php artisan migrate and confirm the default tables appear. If both work, your web server, PHP, database, and Laravel are all talking to each other — every future bug is now an application bug, not an environment mystery. This checkpoint takes three minutes and saves hours of misdirected debugging later.
The Install Errors That Actually Happen
Three failures cover nearly every broken Laravel 12 install. A could not find driver on migration means the PHP database extension is missing — install pdo_mysql (or pdo_pgsql) and restart PHP. A 500 with a blank screen right after install is almost always permissions on storage/ and bootstrap/cache/ — the web server user needs write access to both. And a composer install that dies on memory can be run as COMPOSER_MEMORY_LIMIT=-1 composer install. Bookmark these three; they account for the majority of "Laravel is broken" moments on fresh machines.
Setting Up for the Long Run
Two habits turn a working install into a professional environment. First, commit a .env.example that documents every variable your app needs, so the next machine — or the next developer — configures itself from a template instead of tribal knowledge. Second, install Laravel Pint and run it before commits: consistent formatting from the first file means no formatting-noise diffs forever after. Neither takes ten minutes, and both keep paying off for the life of the project.
Understanding What the Installer Gave You
Take five minutes to walk the directory tree before writing code — it repays itself immediately. routes/ holds every entry point; app/Http/Controllers is where request handling lives; config/ mirrors every .env value with sensible defaults; and storage/ is the only place the framework writes at runtime, which is why its permissions matter and why it never belongs in version control. Knowing where things live is half of Laravel fluency; the other half is knowing that almost everything is swappable through config/ without touching vendor code.
The Toolchain Around the Framework
Laravel 12 assumes a modern toolchain, and matching it removes a whole category of friction. Use PHP 8.3 or newer, keep Composer itself updated, and run npm install && npm run dev once so Vite serves your assets — the default welcome page looks broken without it, which confuses more beginners than any real error. If you're on macOS, Laravel Herd gives you PHP, nginx, and DNS in one install; on any platform, the built-in php artisan serve is enough for the whole tutorial phase. Pick one setup and stop optimizing it — the framework rewards people who ship features, not people who tune environments.
A Word on Versions and Upgrades
Laravel releases yearly now, and minor updates land weekly — run composer update inside a version constraint like ^12.0 freely, but treat major upgrades as scheduled work with the upgrade guide open. The skills from this setup carry directly into Laravel 13 and beyond: the installer changes rarely, the directory tree changes almost never, and the environment discipline you built here is exactly what makes future upgrades a diff instead of a rebuild. Starting clean on 12 today is also the best preparation for maintaining older projects, because you now know what a healthy baseline looks like and can spot the drift in anything legacy.
Keep this page bookmarked for your next machine. A documented install you can repeat in twenty minutes is worth more than a perfect one you can't reproduce — and the second time through, you'll notice which steps your muscle memory already owns. That's the real graduation from tutorial to toolkit, and it happens faster than you'd expect.
And if a teammate asks why their fresh clone won't boot, you already know the checklist: env file, app key, database exists, storage writable.
After the Install
A clean Laravel 12 installation setup is the boring foundation everything else rests on — get the environment right once and every future project starts in minutes. My the Laravel 13 guide and automated deploys go deeper.
If you want your Laravel environment standardized, that's work I take on through Ramlit.