Enterprise applications require stability. Laravel 6 LTS provides 3 years of support with bug fixes and security patches. At ZIRA Software, Laravel 6 LTS powers production applications serving millions of users.
LTS Support Timeline
Laravel 6 LTS (September 2019 - September 2022):
- Bug fixes: Until September 2021 (2 years)
- Security fixes: Until September 2022 (3 years)
- PHP support: 7.2 - 8.0
Why choose LTS:
- Extended support for stability
- Predictable upgrade schedule
- Reduced maintenance overhead
- Enterprise confidence
Production Optimization
Cache configuration:
# Cache all configurations
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Clear caches
php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear
Composer optimization:
composer install --optimize-autoloader --no-dev --prefer-dist
# Generate optimized autoload files
composer dump-autoload --optimize --classmap-authoritative
Queue workers:
# Efficient queue processing
php artisan queue:work --sleep=3 --tries=3 --max-time=3600
Deployment Strategy
Zero-downtime deployment:
#!/bin/bash
# deployment.sh
# Pull latest code
git pull origin main
# Install dependencies
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
# Run migrations (without downtime)
php artisan migrate --force
# Clear and cache
php artisan config:cache
php artisan route:cache
php artisan view:cache
# Reload queue workers gracefully
php artisan queue:restart
# Reload PHP-FPM
sudo service php7.4-fpm reload
Using Laravel Envoy:
{{-- Envoy.blade.php --}}
@servers(['production' => 'user@production-server'])
@setup
$repository = 'git@github.com:zirasoftware/project.git';
$releases_dir = '/var/www/releases';
$app_dir = '/var/www/html';
$release = date('YmdHis');
$new_release_dir = $releases_dir . '/' . $release;
@endsetup
@story('deploy')
clone_repository
run_composer
update_symlinks
run_migrations
optimize
reload_services
@endstory
@task('clone_repository')
echo 'Cloning repository'
[ -d {{ $releases_dir }} ] || mkdir {{ $releases_dir }}
git clone --depth 1 {{ $repository }} {{ $new_release_dir }}
cd {{ $new_release_dir }}
git reset --hard {{ $commit }}
@endtask
@task('run_composer')
echo "Starting deployment ({{ $release }})"
cd {{ $new_release_dir }}
composer install --prefer-dist --no-scripts --no-dev -q -o
@endtask
@task('update_symlinks')
echo "Linking storage directory"
rm -rf {{ $new_release_dir }}/storage
ln -nfs {{ $app_dir }}/storage {{ $new_release_dir }}/storage
echo 'Linking .env file'
ln -nfs {{ $app_dir }}/.env {{ $new_release_dir }}/.env
echo 'Linking current release'
ln -nfs {{ $new_release_dir }} {{ $app_dir }}/current
@endtask
@task('run_migrations')
cd {{ $new_release_dir }}
php artisan migrate --force
@endtask
@task('optimize')
cd {{ $new_release_dir }}
php artisan config:cache
php artisan route:cache
php artisan view:cache
@endtask
@task('reload_services')
sudo service php7.4-fpm reload
php artisan queue:restart
@endtask
Monitoring and Logging
Configure logging:
// config/logging.php
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['daily', 'slack'],
'ignore_exceptions' => false,
],
'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
],
],
Application health monitoring:
// routes/web.php
Route::get('/health', function () {
$checks = [
'database' => checkDatabase(),
'redis' => checkRedis(),
'queue' => checkQueue(),
'storage' => checkStorage(),
];
$healthy = collect($checks)->every(fn($status) => $status === true);
return response()->json([
'status' => $healthy ? 'healthy' : 'unhealthy',
'checks' => $checks,
'timestamp' => now(),
], $healthy ? 200 : 503);
});
function checkDatabase()
{
try {
DB::connection()->getPdo();
return true;
} catch (\Exception $e) {
return false;
}
}
function checkRedis()
{
try {
Redis::ping();
return true;
} catch (\Exception $e) {
return false;
}
}
function checkQueue()
{
try {
$size = Queue::size();
return $size < 10000; // Alert if queue too large
} catch (\Exception $e) {
return false;
}
}
function checkStorage()
{
return is_writable(storage_path());
}
Performance Tuning
Database optimization:
// Use eager loading
$users = User::with(['posts', 'comments'])->get();
// Use chunking for large datasets
User::chunk(1000, function ($users) {
foreach ($users as $user) {
// Process user
}
});
// Use cursors for memory efficiency
foreach (User::cursor() as $user) {
// Process one user at a time
}
// Index frequently queried columns
Schema::table('users', function (Blueprint $table) {
$table->index('email');
$table->index('created_at');
});
Cache strategies:
// Cache query results
$users = Cache::remember('users:active', 3600, function () {
return User::where('active', true)->get();
});
// Cache expensive computations
$stats = Cache::remember('dashboard:stats', 600, function () {
return [
'total_users' => User::count(),
'total_orders' => Order::count(),
'revenue' => Order::sum('total'),
];
});
// Tag-based cache invalidation
Cache::tags(['users', 'posts'])->put('key', $value, 3600);
Cache::tags(['users'])->flush(); // Clear all user-related cache
Queue optimization:
// Job priorities
ProcessHighPriority::dispatch($data)->onQueue('high');
ProcessLowPriority::dispatch($data)->onQueue('low');
// Supervisor configuration for priorities
[program:laravel-worker-high]
command=php artisan queue:work --queue=high,default --sleep=3 --tries=3
numprocs=4
[program:laravel-worker-default]
command=php artisan queue:work --queue=default --sleep=3 --tries=3
numprocs=2
Security Best Practices
1. Environment configuration:
APP_ENV=production
APP_DEBUG=false
APP_KEY=base64:... # Generate with: php artisan key:generate
2. HTTPS enforcement:
// app/Providers/AppServiceProvider.php
public function boot()
{
if (app()->environment('production')) {
URL::forceScheme('https');
}
}
3. Rate limiting:
// routes/api.php
Route::middleware('throttle:60,1')->group(function () {
Route::get('/api/users', [UserController::class, 'index']);
});
4. Security headers:
// app/Http/Middleware/SecurityHeaders.php
public function handle($request, Closure $next)
{
$response = $next($request);
$response->headers->set('X-Frame-Options', 'SAMEORIGIN');
$response->headers->set('X-Content-Type-Options', 'nosniff');
$response->headers->set('X-XSS-Protection', '1; mode=block');
$response->headers->set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
return $response;
}
Backup Strategy
Database backups:
# Using spatie/laravel-backup
composer require spatie/laravel-backup
php artisan backup:run
// config/backup.php
return [
'backup' => [
'name' => env('APP_NAME', 'laravel-backup'),
'source' => [
'files' => [
'include' => [
base_path(),
],
'exclude' => [
base_path('vendor'),
base_path('node_modules'),
],
],
'databases' => [
'mysql',
],
],
'destination' => [
'disks' => [
's3',
],
],
],
];
Maintenance Mode
# Enable maintenance mode
php artisan down --message="Upgrading database" --retry=60
# Enable with secret bypass
php artisan down --secret="zirasoftware-upgrade"
# Access: https://example.com/zirasoftware-upgrade
# Disable maintenance mode
php artisan up
Conclusion
Laravel 6 LTS provides enterprise-grade stability with extended support. Proper optimization, monitoring, and deployment strategies ensure reliable production applications.
Need enterprise Laravel development? Contact ZIRA Software for production-ready applications.