Laravel Local Development Guide
Run PHP full-stack applications on localhost:8000 using Laravel and Artisan, with optional Sail, Herd, or XAMPP environments.
Laravel is one of the most popular PHP web frameworks, suitable for APIs, backend management, and full-stack applications. Local development typically starts the built-in server on localhost:8000 using php artisan serve.
Default localhost Access
| Method | Address |
|---|---|
php artisan serve | http://localhost:8000 |
| Specified Port | php artisan serve --port=8080 |
| Laravel Sail (Docker) | Port mapping in .env under APP_PORT |
Quick Start
composer create-project laravel/laravel my-app
cd my-app
cp .env.example .env
php artisan key:generate
php artisan serveOpen your browser to http://localhost:8000 to see the Laravel welcome page, indicating success.
Database Configuration
Example .env (MySQL + XAMPP):
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=Migration:
php artisan migrateFor PostgreSQL, set DB_CONNECTION=pgsql and DB_PORT=5432.
Local Environment Options
| Option | Description |
|---|---|
| artisan serve | Quickest setup, suitable for learning and small projects |
| Laravel Sail | Docker encapsulation of PHP, MySQL, Redis, Mailpit |
| Laravel Herd / Valet | Native .test domain for macOS |
| XAMPP / Laragon | Traditional Apache + PHP, configure virtual hosts to point to public/ |
The production-grade directory structure requires the web root to point to public/, avoiding exposure of the entire project to the Apache root directory.
Common Commands
php artisan make:controller UserController
php artisan route:list
php artisan queue:work
php artisan tinker
npm run dev # Vite frontend assets (Laravel 9+)Laravel frontend assets also use Vite; during development, open http://localhost:5173 to load HMR.
Frequently Asked Questions
500 Error / Storage Permissions
Run chmod -R 775 storage bootstrap/cache to ensure the web user has write access.
Vite Assets 404
Run both php artisan serve and npm run dev simultaneously.
Composer Memory Limit
Use COMPOSER_MEMORY_LIMIT=-1 composer install.
Summary
The fastest path for Laravel local development: php artisan serve → http://localhost:8000; for team projects, it is recommended to use Sail or Laragon/Herd to unify PHP versions and extensions.