If you need to know how to create a Laravel project that actually runs in production, the answer fits in two commands. Install Composer, then run composer create-project laravel/laravel your-app. From there, configure your .env, generate an app key, and launch php artisan serve. The rest of this guide unpacks every realistic decision around that workflow: choosing between the Installer and Composer, picking Sail versus native PHP, wiring up MySQL or MongoDB, and avoiding the rookie mistakes that turn a five‑minute setup into a weekend of stack traces.

Overview & Quick Answer
What you'll learn
This guide walks through every realistic path for spinning up a Laravel application in 2026: the Composer one‑liner, the global Installer, the Docker‑based Sail environment, and production stacks like Nginx + PHP‑FPM or AWS Lambda through Bref. You'll see concrete commands, dependency requirements, and the trade‑offs that separate hobby projects from scalable SaaS.
Fastest path for new developers
For a brand‑new developer on macOS, Linux, or Windows with PHP 8.2+ and Composer installed, the shortest route looks like this:
composer create-project laravel/laravel my-app
cd my-app
php artisan key:generate
php artisan serve
That is the canonical answer for how to create a Laravel project from scratch. Everything else in this article is about scaling, customizing, or hardening that baseline.
Definition: Laravel is an open‑source PHP web application framework that follows the MVC architectural pattern. It bundles routing, ORM (Eloquent), templating (Blade), queues, and a CLI called Artisan so you can ship production features without hand‑rolling the boilerplate.
Why Laravel Stays Relevant in 2026
Modern PHP ecosystem
PHP 8.2 and 8.3 ship with readonly classes, fibers, and a JIT that materially trims response times on CPU‑bound routes. Laravel 12, the current release line, leans into those features: the framework drops PHP 8.1 support, hardens typed property promotion, and ships native support for AI scaffolding through Laravel Boost. PHP is no longer the language people joke about; it powers Netflix, Facebook, LinkedIn, 9GAG, the BBC, and Pfizer's marketing stack.
Community and ecosystem growth
Packagist lists over 410,000 packages, and Laravel‑specific packages dominate the top‑ranked tags. The community publishes daily on Laravel News, the official Laravel/core repo bundles tutorials and docs inside the starter project, and ecosystem tools like Herd, Forge, and Vapor keep improving every quarter.
Long‑term support and LTS
Laravel follows a yearly major release with an 18‑month bug‑fix window and a 30‑month security window. Laravel 12 sits in active support throughout 2026, and Laravel 11 remains security‑patched until late 2027. That kind of lifecycle math is rare in dynamic‑language frameworks and is a major reason enterprise teams keep greenlighting Laravel.
Prerequisites and System Requirements
PHP and Composer versions
Laravel 12 requires PHP 8.2 or higher. Confirm your runtime with php -v; if you see 8.1 or lower, follow the SitePoint beginner guide to install a newer PHP build or use Laravel Herd for a one‑click environment. Composer 2.x is mandatory. Install it from getcomposer.org and verify with composer --version.
Database options
Laravel supports the major relational engines out of the box: MySQL 8, MariaDB 10.6+, and PostgreSQL 14+. On Ubuntu you can pull MariaDB with sudo apt install mariadb-server per the Hostinger Ubuntu walkthrough. If your project leans on document‑style data or vector search, install the MongoDB PHP Extension, add it to php.ini, and require the mongodb/laravel-mongodb package. MongoDB Atlas works as a managed backend and unlocks MongoDB Vector Search for AI‑driven recommendations.
Optional tools
Docker and Docker Compose unlock Laravel Sail. Laravel Homestead is a Vagrant box pre‑configured with PHP, Nginx, MySQL, and Redis for legacy or VM‑based workflows. Laravel Herd is the modern macOS/Windows native alternative. Pick one, document it, and stick to it across the team.
Project Creation Options (Composer vs Installer)
Installing Composer locally
If Composer isn't on your machine, the official installer from getcomposer.org handles Linux, macOS, and Windows in a single curl pipe. On Debian‑based systems you can also use the APT repository. Verify installation with composer --version before moving on.
Running composer create-project
This is the lowest‑dependency method and works on any machine with PHP and Composer. The pattern is:
composer create-project laravel/laravel my-app
cd my-app
php artisan serve
Append --git to scaffold a fresh git repo, or --branch="main" to pin a specific branch, as documented in Snyk's Laravel security tips. This is the recommended answer to how to create a Laravel project in CI environments where global installs are restricted.
Installing Laravel Installer globally
For local development, the global installer speeds things up:
composer global require laravel/installer
export PATH="$HOME/.composer/vendor/bin:$PATH"
laravel new my-app
Make sure Composer's global bin directory is on your PATH, as the SitePoint setup guide highlights. The installer adds a few niceties like pre‑installed Git initialization and a slightly faster scaffolding step.
Choosing the right method
Use composer create-project in CI, Dockerfiles, and any time you need a reproducible, dependency‑locked bootstrap. Use the global installer when you spin up multiple projects a day and want a one‑word command.
Environment Setup and Local Server
Configuring .env and database
Open .env and fill in the database section. For MariaDB on Ubuntu, the typical values are:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_app
DB_USERNAME=my_app
DB_PASSWORD=secret
For MongoDB, set MONGODB_URI with your Atlas connection string, per the Laravel News MongoDB tutorial.
Generating application key
Run php artisan key:generate. This writes a 32‑character random string into APP_KEY, which Laravel uses for encryption and signed URLs. Without it, sessions and CSRF tokens behave unpredictably.
Running php artisan serve
Start the built‑in PHP server with php artisan serve; it defaults to http://127.0.0.1:8000. This is a development‑only server and the Hostinger Artisan command reference is a good place to learn the surrounding command‑line options.
Using the built‑in queue worker
For background jobs, run php artisan queue:work in a second terminal. In production you'll graduate to Supervisor, Horizon, or a managed worker pool, but locally this is the lowest‑friction option.
Docker Sail for Consistent Development
Installing Sail
Laravel Sail is a thin CLI over Docker Compose that ships with new Laravel projects. To add it to an existing app, run composer require laravel/sail --dev and publish its Dockerfile with php artisan sail:install. You can also install Sail globally via composer global require laravel/sail as described in HackerNoon's Sail guide.
Running sail up
./vendor/bin/sail up
./vendor/bin/sail down
./vendor/bin/sail logs
./vendor/bin/sail ps
The up command brings up PHP, Nginx, MySQL, and Redis containers. Once Sail is running, your app responds at http://localhost. Use sail artisan in place of php artisan to run commands inside the container.
Customizing docker-compose.yml
Need Meilisearch or a different Node version? Edit docker-compose.yml at the project root. Sail exposes a clean declarative format that the team can review in pull requests, which kills the "works on my machine" problem that plagues most PHP shops.
Sail vs. local server trade‑offs
Sail gives you parity with production but burns more RAM and slows file syncing on macOS. The built‑in php artisan serve is lighter and faster for solo work. For a team larger than two developers, Sail almost always wins because every laptop runs the exact same image.
Production‑Ready Deployment Options
Nginx + PHP‑FPM
The classic LEMP stack: Nginx fronts the app, PHP‑FPM executes Laravel, and MySQL or MariaDB handles storage. It's battle‑tested, cheap, and easy to operate. Most managed hosts (Hostinger, DigitalOcean, Linode) ship one‑click Laravel installers on top of this stack.
Docker container for production
Build a production Dockerfile based on php:8.2-fpm, ship it to any registry, and run it behind a load balancer. Laravel's official Docker images on Docker Hub are a sane starting point. Add a separate container for the queue worker and a third for the scheduler.
Serverless with Bref and Lambda
For spiky or unpredictable workloads, Bref plus AWS SAM is the modern serverless path:
composer require bref/laravel-bridge
git clone https://github.com/aws-samples/php-examples-for-aws-lambda/
cd 0.4-Building-A-Serverless-Laravel-App-With-AWS-SAM
sam deploy -g
You'll need to set SESSION_DRIVER=cookie and push logs to Amazon CloudWatch. Amazon CloudFront handles static delivery. The pattern is fully laid out in AWS's serverless LAMP walkthrough.
Choosing the right host
For predictable traffic, pick a VPS with Nginx + PHP‑FPM. For unpredictable or bursty workloads, Bref on Lambda removes idle cost. For zero‑ops, Laravel Forge on DigitalOcean or AWS, or Laravel Vapor (an AWS‑native serverless platform), is the lowest‑friction option.
Trade‑offs, Performance, and Maintenance
Speed vs. complexity
Laravel trades raw throughput for developer ergonomics. A vanilla PHP‑FPM setup will beat a Laravel app on a synthetic benchmark, but the time you save on auth, validation, queues, and ORM is almost always worth more than the milliseconds you lose.
Scaling considerations
Horizontal scaling requires stateless app servers, an external session driver (Redis or database), and a managed queue (SQS, Beanstalkd, or Redis). Octane can squeeze an order‑of‑magnitude more throughput from a single node, but most teams scale out before they scale up.
Updating dependencies and Laravel upgrades
Run composer update on a branch, run your test suite, then merge. Laravel Shift automates most of the upgrade work between major versions. Subscribe to the Laravel News release feed so you never miss a security advisory.
Common Mistakes and Troubleshooting
Permission and ownership issues
Storage and bootstrap/cache must be writable by the PHP process. On Linux, run chmod -R ug+rwx storage bootstrap/cache and make sure the web user owns the directory. Skipping this is the most common cause of 500 errors on a fresh deploy.
Composer cache and autoload problems
If Composer hangs or reports "Class not found," clear the autoloader with composer dump-autoload. For deeper corruption, run composer clear-cache then reinstall dependencies.
Database connection errors
Double‑check credentials in .env, confirm the database server is listening on the right port, and ensure the user has privileges on the target schema. On MariaDB, you can verify with sudo systemctl status mariadb and sudo ufw allow "Apache Full" to make sure the firewall isn't blocking traffic.
Queue worker failures
If jobs sit in the database without running, the worker process has crashed or never started. Check Supervisor or systemd logs. Make sure QUEUE_CONNECTION matches the driver you intend to use.
Verdict: Most Laravel setup pain is configuration drift, not framework bugs. Treat your .env, PHP extensions, and process manager as first‑class parts of the deployment pipeline and you'll rarely hit the wall.
Who Should Use Which Setup? (Table)
| Target Persona | Recommended Option | Key Reason & Real‑World Benefit |
|---|---|---|
| Solo hobby developer | Composer create-project + php artisan serve | Zero install overhead, fastest iteration loop, no Docker resource cost. |
| Small team (2–5 devs) | Laravel Sail on Docker | Every laptop runs the same containers, eliminating environment drift. |
| Agency / multi‑project shop | Laravel Installer + Sail | One‑word scaffolding for new projects and a consistent dev stack across clients. |
| Enterprise / regulated workload | Nginx + PHP‑FPM on hardened VPS or Kubernetes | Full control over PHP extensions, opcache tuning, and audit trails. |
| SaaS with bursty traffic | Bref + AWS Lambda with CloudFront | No idle cost, automatic scaling, pay‑per‑invocation pricing. |
| AI / vector search app | Laravel + MongoDB Atlas + Laravel Boost | Vector embeddings, semantic search, and AI scaffolding out of the box. |