Shipping Your Application
A reliable deployment process is repeatable, automated, and safe.
Deployment Script
#!/bin/bash
git pull origin main
composer install --no-dev --optimize-autoloader
npm ci && npm run build
php artisan migrate --force
php artisan optimize
php artisan filament:optimize
rm -f public/hot
php artisan horizon:terminate
sudo systemctl reload php8.3-fpm
Production Environment
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourapp.com
QUEUE_CONNECTION=redis
CACHE_STORE=redis
SESSION_DRIVER=redis
LOG_CHANNEL=daily
LOG_LEVEL=error
GitHub Actions CI/CD
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy
run: |
rsync -avz --delete ./ user@server:/var/www/app/
ssh user@server "cd /var/www/app && ./deploy.sh"
Pre-Deployment Checklist
php artisan test # 1. All tests pass
vendor/bin/pint # 2. Code formatted
npm run build # 3. Assets compiled
composer install --no-dev # 4. No dev dependencies
Nginx Configuration
server {
listen 443 ssl http2;
server_name yourapp.com;
root /var/www/app/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
Automate deployment early. A reliable pipeline is what separates side projects from professional applications.