| name | laravel-deployment |
| description | Laravel deployment patterns for Forge, Vapor, and manual deployment. |
Laravel Deployment
Pre-Deploy Checklist
Laravel Forge (Recommended)
Setup
- Create server on Forge
- Connect Git repository
- Configure environment variables
- Set up deployment script
Deployment Script (Forge)
cd /home/forge/your-app
git pull origin main
composer install --no-dev --optimize-autoloader
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
php artisan queue:restart
npm ci
npm run build
Laravel Vapor (Serverless)
Setup
composer require laravel/vapor-cli --dev
./vendor/bin/vapor login
./vendor/bin/vapor init
Deploy
./vendor/bin/vapor deploy production
Manual Deployment
Full Script
php artisan down --refresh=15
git pull origin main
composer install --no-dev --optimize-autoloader
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
php artisan queue:restart
npm ci
npm run build
php artisan up
Zero-Downtime Deploy
Using Envoyer
- Atomic deployments
- Health checks
- Rollback support
Key Concepts
- Deploy to new release folder
- Run migrations
- Symlink
current to new release
- Restart queue workers
Environment Configuration
Required Variables
APP_ENV=production
APP_DEBUG=false
APP_KEY=base64:...
DB_CONNECTION=mysql
DB_HOST=your-db-host
DB_DATABASE=your-database
DB_USERNAME=your-user
DB_PASSWORD=your-password
QUEUE_CONNECTION=redis
CACHE_DRIVER=redis
SESSION_DRIVER=redis
Security
- Never commit
.env
- Use Forge/Vapor secrets management
- Rotate APP_KEY only with care
Post-Deploy Verification
Rollback
Quick Rollback
php artisan migrate:rollback
git revert HEAD
Full Rollback (with Forge/Envoyer)
- Use "Rollback" feature in dashboard
- Points to previous release folder
Production Optimizations
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
composer install --optimize-autoloader --no-dev