Getting Started with Laravel 12
Getting Started with Laravel 12
Getting Started with Laravel 12
Tip: Skip the Laravel Installer
You don't need laravel/installer globally. Just use Composer directly:
composer create-project laravel/laravel myapp
The installer is just a thin wrapper. Composer does the same thing.
Tip: Use --no-dev for Production
When deploying, install without dev dependencies:
composer install --no-dev --optimize-autoloader
This shaves off ~50 packages you don't need in production.
Gotcha: The .env File is NOT for Production
Never commit .env. Use actual environment variables on your server. The .env file is for local development only.
Tip: Run php artisan optimize After Deployment
php artisan config:cache
php artisan route:cache
php artisan view:cache
This caches everything and speeds up your app significantly.
Gotcha: SQLite is Not for Production
Laravel defaults to SQLite for quick starts. Switch to PostgreSQL or MySQL before you go live. SQLite doesn't handle concurrent writes well.
Tip: Use php artisan serve Only for Development
It's a single-threaded PHP server. For anything serious, use Nginx or Apache.
Tip: The APP_KEY is Critical
If you lose your APP_KEY, all encrypted data (sessions, cookies, encrypted columns) becomes unreadable. Back it up.
Tip: Use route:cache Carefully
php artisan route:cache is fast, but it doesn't work with closure-based routes. Every time you cache routes, Laravel serializes them. If you have Route::redirect() or closure callbacks, the cache breaks. Stick to controller-based routes in production.
Tip: Model APP_KEY Rotation
Rotating APP_KEY invalidates all encrypted data — cookies, encrypted DB columns, and password reset tokens. If you must rotate (e.g., after a leak), plan a migration that re-encrypts existing data with the new key.
Gotcha: Local Scope Leaks
Global scopes defined in booted() apply to ALL queries on that model — including relationships. An innocent User::all() in admin panel might exclude soft-deleted users if a global scope is active.
Senior Insight
I've onboarded dozens of developers onto Laravel projects, and the single biggest friction point is environment setup. I recommend investing in a Docker Compose setup tailored to your stack rather than relying solely on Sail — the 30 minutes you spend configuring it upfront saves days of 'works on my machine' debugging. Also, run php artisan about after any major upgrade; it gives you a complete environment snapshot and often reveals misconfigured drivers before they cause production issues.
Source: Laravel News (https://laravel-news.com/), Freek.dev (https://freek.dev/tags/laravel), Spatie Blog (https://spatie.be/blog)