agentleFS
G1JoshiG1Joshi/Agent-Skills/skills/frameworks/laravel/SKILL.md

laravel

Skill15 starsChanged 43 days agoMITView on GitHub

Expert Laravel assistance covering Eloquent ORM, Blade templating, queues, service providers, and Artisan CLI. Use when developing enterprise PHP web applications and robust REST APIs.

  • Reads credentials

14 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use Form Requests for input validation instead of validating inline inside controllers.

    line 171
  2. Distinctive:

    Run queue workers under supervisor with Redis for reliable background job execution.

    line 173
  3. Distinctive:

    Run migrations directly in production without a verified backup and dry run.

    line 178
  4. Very specific:

    Commit the .env file to source control.

    line 179

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Laravel

Laravel is an expressive PHP web application framework providing an elegant developer experience with Eloquent ORM, robust queues, events, and native real-time broadcasting.

When to Use

  • Enterprise Full-Stack PHP Web Applications: Building robust web portals with Eloquent ORM, Blade, and queues.
  • Modern Monoliths with Inertia.js: Pairing Laravel backend routes directly with React or Vue frontends without API boilerplate.
  • High-Velocity REST APIs: Utilizing Laravel API Resources, Sanctum authentication, and Form Requests.
  • Real-Time Applications with Laravel Reverb: First-party WebSocket broadcasting and real-time dashboard events.

Quick Start

// routes/web.php
Route::get('/', function () {
    return view('welcome');
});

// app/Models/User.php
// Elegant Active Record
$users = User::where('active', 1)->get();

Core Concepts

Eloquent ORM with Relationships & Scopes

Expressive database models with type hinting:

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Builder;

class Customer extends Model
{
    protected $fillable = ['name', 'email', 'is_active'];

    public function orders(): HasMany
    {
        return $this->hasMany(Order::class);
    }

    // Local query scope
    public function scopeActive(Builder $query): void
    {
        $query->where('is_active', true);
    }
}

Form Requests & Validated Controllers

Strict input validation separated from controller logic:

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreOrderRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    public function rules(): array
    {
        return [
            'customer_id' => 'required|exists:customers,id',
            'amount' => 'required|numeric|min:0.01',
            'items' => 'required|array|min:1',
            'items.*.product_id' => 'required|integer',
            'items.*.qty' => 'required|integer|min:1',
        ];
    }
}

// In Controller:
namespace App\Http\Controllers;

use App\Http\Requests\StoreOrderRequest;
use App\Models\Order;
use Illuminate\Http\JsonResponse;

class OrderController extends Controller
{
    public function store(StoreOrderRequest $request): JsonResponse
    {
        $validated = $request->validated();
        $order = Order::create($validated);

        return response()->json($order, 201);
    }
}

Asynchronous Queue Workers & Jobs

Offloading heavy processing to Redis or SQS workers:

namespace App\Jobs;

use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Mail;

class ProcessInvoiceJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function __construct(public Order $order) {}

    public function handle(): void
    {
        // Generate PDF and send invoice email
    }
}

Common Patterns

Eloquent Scope and Queue Dispatch

Problem: Processing heavy invoice calculations synchronously blocks user HTTP requests.

Solution: Dispatch queued jobs with Eloquent local scopes:

namespace App\Http\Controllers;

use App\Models\Order;
use App\Jobs\ProcessInvoiceJob;
use Illuminate\Http\JsonResponse;

class OrderController extends Controller
{
    public function complete(int $id): JsonResponse
    {
        $order = Order::active()->findOrFail($id);
        $order->update(['status' => 'completed']);

        // Dispatch to background queue worker
        ProcessInvoiceJob::dispatch($order)->onQueue('invoices');

        return response()->json(['message' => 'Order completed, invoice queued']);
    }
}

Best Practices

Do:

  • Target Laravel 11/12 with streamlined application structure and minimal configuration files.
  • Use Form Requests for input validation instead of validating inline inside controllers.
  • Utilize Eloquent eager loading (with(['customer', 'items'])) to prevent N+1 queries.
  • Run queue workers under supervisor with Redis for reliable background job execution.

Don't:

  • Execute raw database queries in Blade views or controllers; use Eloquent or repository classes.
  • Run migrations directly in production without a verified backup and dry run.
  • Commit the .env file to source control.

Troubleshooting

ErrorCauseSolution
No application encryption key has been specifiedAPP_KEY missing in .env configuration file.Run php artisan key:generate.
Class '...' not found / Target class does not existNamespace mismatch or service provider not loaded.Run composer dump-autoload and check namespace in config/app.php.
SQLSTATE[HY000] [2002] Connection refusedDatabase service down or .env DB host/port misconfigured.Verify database credentials and host (127.0.0.1 vs localhost).

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.