laravel-infrastructure
Laravel Infrastructure
Horizon, Octane, Reverb, Redis, and PostgreSQL patterns for Laravel 12+.
Horizon (Queue Management)
Installation
composer require laravel/horizon
php artisan horizon:install
php artisan migrate
Configuration
// config/horizon.php
'environments' => [
'production' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['default', 'high', 'low'],
'balance' => 'auto',
'maxProcesses' => 10,
'minProcesses' => 1,
'memory' => 128,
'tries' => 3,
'timeout' => 60,
],
],
'local' => [
'supervisor-1' => [
'connection' => 'redis',
'queue' => ['default'],
'balance' => 'simple',
'processes' => 3,
'tries' => 3,
],
],
],
Running Horizon
# Development
php artisan horizon
# Production (with Supervisor)
# /etc/supervisor/conf.d/horizon.conf
[program:horizon]
process_name=%(program_name)s
command=php /var/www/app/artisan horizon
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stdout_logfile=/var/www/app/storage/logs/horizon.log
stopwaitsecs=3600
Dispatching Jobs
// Dispatch to specific queue
ProcessOrder::dispatch($order)->onQueue('high');
// Delayed dispatch
ProcessOrder::dispatch($order)->delay(now()->addMinutes(5));
// Chain jobs
Bus::chain([
new ProcessOrder($order),
new SendConfirmation($order),
new NotifyWarehouse($order),
])->dispatch();
Octane (High Performance)
Installation
composer require laravel/octane
php artisan octane:install
# Choose: Swoole or RoadRunner
Running
# Development
php artisan octane:start --watch
# Production
php artisan octane:start --workers=4 --task-workers=6
Important: Memory Leaks
// AVOID: Static properties accumulating data
class BadService
{
private static array $cache = []; // Memory leak!
}
// GOOD: Use request-scoped or proper cache
class GoodService
{
public function __construct(
private readonly Repository $cache
) {}
}
Octane-Safe Patterns
// Reset singletons between requests
// AppServiceProvider
public function register(): void
{
$this->app->singleton(ShoppingCart::class, function ($app) {
return new ShoppingCart();
});
}
// In Octane config
'flush' => [
ShoppingCart::class,
],
Reverb (WebSockets)
Installation
composer require laravel/reverb
php artisan reverb:install
Configuration
BROADCAST_DRIVER=reverb
REVERB_APP_ID=my-app
REVERB_APP_KEY=my-key
REVERB_APP_SECRET=my-secret
REVERB_HOST=localhost
REVERB_PORT=8080
Running
php artisan reverb:start
Broadcasting Events
<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
class OrderStatusUpdated implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets;
public function __construct(
public Order $order
) {}
public function broadcastOn(): array
{
return [
new Channel('orders.' . $this->order->id),
];
}
public function broadcastAs(): string
{
return 'status.updated';
}
}
Frontend (Laravel Echo)
Echo.channel('orders.123')
.listen('.status.updated', (event) => {
console.log('Order status:', event.order.status);
});
Redis
Caching
use Illuminate\Support\Facades\Cache;
// Store
Cache::put('key', 'value', now()->addMinutes(10));
Cache::forever('key', 'value');
// Retrieve
$value = Cache::get('key', 'default');
$value = Cache::remember('key', 60, fn () => expensive());
// Remove
Cache::forget('key');
Cache::flush();
// Tags
Cache::tags(['users', 'orders'])->put('user:1:orders', $orders, 60);
Cache::tags(['users'])->flush();
Sessions
SESSION_DRIVER=redis
Locks
$lock = Cache::lock('processing-order-' . $orderId, 10);
if ($lock->get()) {
try {
// Process order
} finally {
$lock->release();
}
}
PostgreSQL
Configuration
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=myapp
DB_USERNAME=postgres
DB_PASSWORD=secret
PostgreSQL-Specific Features
// JSONB columns
Schema::create('settings', function (Blueprint $table) {
$table->id();
$table->jsonb('data')->default('{}');
$table->index('data', 'settings_data_gin')->using('gin');
});
// Query JSONB
$users = User::whereJsonContains('settings->notifications', 'email')->get();
$users = User::where('settings->theme', 'dark')->get();
// Full-text search
$products = Product::whereFullText('name', 'laptop')->get();
References
| Topic | Reference | When to Load |
|---|---|---|
| Horizon details | references/horizon.md | Supervisor, tags, batches |
| Octane caveats | references/octane.md | Memory, concurrency |
| Reverb channels | references/reverb.md | Private/presence channels |
Quick Commands
# Horizon
php artisan horizon
php artisan horizon:status
php artisan horizon:pause
php artisan horizon:continue
php artisan horizon:terminate
# Octane
php artisan octane:start
php artisan octane:reload
php artisan octane:stop
# Reverb
php artisan reverb:start
# Cache
php artisan cache:clear
php artisan config:cache
php artisan route:cache
More from anilcancakir/my-claude-code
flutter-design
Flutter/Dart implementation patterns for Refactoring UI principles. COMPANION skill for mobile-app-design-mastery. ALWAYS activate for: Flutter theming, ThemeData, ColorScheme, TextTheme, BoxDecoration, Material 3, Flutter shadows, Flutter spacing, Flutter typography, Flutter dark mode, Flutter components, Flutter styling, Dart UI, Widget decoration. Provides ThemeData setup, color schemes, typography styles, spacing utilities, decoration patterns. Turkish: Flutter tema, Flutter renk, Flutter tasarım, Dart UI, widget stil. English: Flutter theming, Material Design, Flutter styling, widget decoration.
74tailwindcss-design
TailwindCSS implementation patterns for Refactoring UI principles. COMPANION skill for web-design-mastery. ALWAYS activate for: TailwindCSS, Tailwind classes, utility classes, Tailwind config, Tailwind components, Tailwind dark mode, Tailwind responsive, Tailwind spacing, Tailwind typography, Tailwind colors, Tailwind shadows. Provides class recipes, component patterns, dark mode implementation, responsive patterns. Turkish: Tailwind kullanımı, Tailwind class, utility CSS, Tailwind config. English: Tailwind patterns, utility-first CSS, Tailwind best practices.
56mobile-app-design-mastery
Production-grade mobile application UI design based on Refactoring UI principles. ALWAYS activate for: Flutter app, mobile app, iOS app, Android app, mobile UI, app screens, mobile navigation, bottom sheets, mobile forms, touch targets, mobile typography, app color scheme, mobile cards, list views, mobile modals, tab bars, app bars, floating action buttons. Provides mobile design workflow, touch-optimized spacing, mobile typography scale, platform-aware patterns. Turkish: mobil uygulama tasarımı, Flutter tasarım, uygulama arayüzü, mobil UI, telefon uygulaması, Android tasarım, iOS tasarım. English: app design, mobile interface, touch-friendly, native feel, mobile UX.
34web-design-mastery
Production-grade web application UI design based on Refactoring UI principles. ALWAYS activate for: landing page, dashboard, auth screens, hero sections, card design, button design, form inputs, navigation, layouts, spacing decisions, typography hierarchy, color selection, shadows, depth, empty states, background decoration. Provides design workflow, visual hierarchy, spacing systems (4px grid), type scale, HSL color systems, shadow elevation, finishing touches. Turkish: sayfa tasarımı, UI/UX, frontend tasarım, web tasarım, güzel arayüz, modern tasarım, card tasarımı, buton stili, form tasarımı, renk paleti, tipografi. English: beautiful interface, sleek design, premium feel, visual hierarchy, whitespace, color palette, typography scale.
33laravel-api-architect
Laravel API development, REST endpoints, JSON responses, Sanctum/Passport authentication, Service-Repository pattern. ALWAYS activate when: working with routes/api.php, app/Http/Controllers/Api/, API endpoints, token authentication, mobile backend, API Resource, JsonResponse, FormRequest, Policy. Triggers on: endpoint çalışmıyor, API hatası, API error, 401 unauthorized, 403 forbidden, 422 validation, token expired, login endpoint, register API, CRUD operations, postman, fetch request, axios, mobile backend, webhook, OAuth, JWT, auth guard, rate limit, throttle, response format, pagination API.
10laravel-fullstack
Laravel Blade views, Alpine.js, Vue.js integration, TailwindCSS styling, Vite assets. ALWAYS activate when: working with resources/views/, Blade components, frontend forms, UI elements, modals, dropdowns, forms. Triggers on: görünmüyor, gösterilmiyor, sayfa yüklenmiyor, sayfa açılmıyor, form çalışmıyor, form gönderilmiyor, buton çalışmıyor, button not working, style bozuk, CSS bozuk, renk yanlış, color wrong, responsive bozuk, mobile görünüm, dark mode çalışmıyor, layout bozuk, component çalışmıyor, modal açılmıyor, dropdown çalışmıyor, asset yüklenmiyor, image not loading, JS error, JavaScript hatası.
10