All skills
asyrafhussin avatar

/laravel-best-practices

@ef59186

Laravel 13 conventions and best practices. Use when creating controllers, models, migrations, validation, services, or structuring Laravel applications. Triggers on tasks involving Laravel architecture, Eloquent, database, API development, or PHP patterns.

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/laravel-best-practices

This session only. Nothing lands on disk.

rulesarch-queue-routing.md

≈753 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Queue Routing

Impact: MEDIUM (Centralized job queue/connection configuration)

Laravel 13 adds Queue::route() to define default queue and connection routing for jobs in a central place, eliminating scattered $connection and $queue properties across job classes.

Bad Example

// Queue/connection config scattered across every job class
namespace App\Jobs;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;

class ProcessPodcast implements ShouldQueue
{
    use Queueable;

    public $connection = 'redis';
    public $queue = 'podcasts';

    public function handle(): void
    {
        // ...
    }
}

class SendNewsletter implements ShouldQueue
{
    use Queueable;

    public $connection = 'redis';
    public $queue = 'emails';

    public function handle(): void
    {
        // ...
    }
}

class GenerateReport implements ShouldQueue
{
    use Queueable;

    public $connection = 'sqs';
    public $queue = 'reports';

    public function handle(): void
    {
        // ...
    }
}

// Problem: To change where podcasts are processed, you must find
// and update every job class individually.

Good Example

// Centralized queue routing in a service provider (Laravel 13+)
namespace App\Providers;

use App\Jobs\GenerateReport;
use App\Jobs\ProcessPodcast;
use App\Jobs\SendNewsletter;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        // Define default queue/connection routing per job class
        Queue::route(ProcessPodcast::class, connection: 'redis', queue: 'podcasts');
        Queue::route(SendNewsletter::class, connection: 'redis', queue: 'emails');
        Queue::route(GenerateReport::class, connection: 'sqs', queue: 'reports');
    }
}
// Job classes stay clean — no routing config needed
namespace App\Jobs;

use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;

class ProcessPodcast implements ShouldQueue
{
    use Queueable;

    public function handle(): void
    {
        // Automatically dispatched to redis/podcasts
    }
}
// Dispatch normally — routing is applied automatically
ProcessPodcast::dispatch($podcast);
SendNewsletter::dispatch($newsletter);
GenerateReport::dispatch($report);

Why

  • Single source of truth: All queue routing in one place — easy to audit and change
  • Clean job classes: Jobs contain only business logic, not infrastructure config
  • Environment flexibility: Override routing per environment without touching job code
  • Discoverable: New developers see all routing decisions in the service provider

Reference: Laravel 13 Documentation — Queues

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill is a comprehensive guide to Laravel 13 best practices, providing safe and standard architectural, database, and security patterns for PHP development. No malicious behavior or security risks were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    1/37 files flagged

  • ZeroLeaks5mo

    2 findings · Score: 80/100

Signed by skilld at ef59186. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
Other metadata
metadata
{
  "author": "Laravel Community",
  "version": "2.1.0",
  "laravelVersion": "13.x",
  "phpVersion": "8.3+"
}

README badge

README badge for asyrafhussin/agent-skills/laravel-best-practices