Skip to content

@tank/laravel-mastery

1.0.0

Description

Production Laravel development from v11+ onward. Eloquent ORM patterns, routing, Blade/Livewire/Inertia frontends, queues, events, authentication (Sanctum/Breeze/Fortify), Pest testing, service container, caching, and deployment (Forge/Vapor/Docker/Octane).

Triggered by

laraveleloquentlaravel modelpest phplaravel apilaravel livewire
Download
Verified
tank install @tank/laravel-mastery

Laravel Mastery

Core Philosophy

  1. Convention over configuration -- Laravel provides sensible defaults for everything. Override only when the default does not fit. Fighting the framework costs more than adapting to it.
  2. Eloquent is not your entire application -- Models handle data access. Business logic belongs in services, actions, or dedicated classes. Fat models become unmaintainable past 500 lines.
  3. Test the behavior, not the implementation -- Write feature tests that hit routes and assert responses. Reserve unit tests for complex, isolated logic. Pest makes this expressive.
  4. Queues are not optional at scale -- Any operation over 500ms (emails, PDFs, API calls, image processing) belongs in a queue. Synchronous execution blocks users and kills throughput.
  5. Cache aggressively, invalidate precisely -- Use tagged caches and cache keys derived from model timestamps. Stale data is worse than no cache.

Quick-Start: Common Problems

"Which frontend stack should I use?"

ScenarioStack
Server-rendered, minimal JSBlade + Alpine.js
Interactive UI, PHP comfortLivewire 3
SPA-like UX with React/VueInertia.js
Decoupled SPA / mobile APISanctum + separate frontend
Admin panelFilament or Nova
-> See references/frontend-and-auth.md

"My Eloquent queries are slow"

  1. Run DB::enableQueryLog() or install Debugbar to count queries
  2. Check for N+1 -- add ->with() for eager loading
  3. Add database indexes on foreign keys and frequently-filtered columns
  4. Use ->select() to limit columns returned
  5. For aggregates, use withCount() or subquery selects instead of loading relations -> See references/eloquent-and-data.md

"How do I structure a large Laravel project?"

  1. Start with default directory layout -- do not reorganize prematurely
  2. Extract business logic into Action classes (single-purpose, invokable)
  3. Use Form Requests for validation, Policies for authorization
  4. Group related features by domain when the app exceeds 30+ models -> See references/architecture-and-operations.md

"Setting up authentication"

  1. New app with UI? Use Breeze (simple) or Jetstream (teams, 2FA)
  2. API only? Run php artisan install:api for Sanctum
  3. SPA + API on same domain? Use Sanctum cookie-based auth
  4. Mobile app? Use Sanctum token-based auth -> See references/frontend-and-auth.md

"My tests are slow or flaky"

  1. Use RefreshDatabase trait -- it wraps each test in a transaction
  2. Use LazilyRefreshDatabase for speed with SQLite in-memory
  3. Avoid hitting real APIs -- use Http::fake() and Queue::fake()
  4. Run parallel tests: php artisan test --parallel -> See references/testing-and-deployment.md

Decision Trees

Queue Driver Selection

SignalDriver
Local developmentsync (immediate) or database
Production, moderate loaddatabase or Redis
Production, high throughputRedis + Horizon
Serverless (Vapor)SQS
Need delayed/scheduled dispatchRedis or SQS

Caching Strategy

DataStrategy
Configuration, routes, viewsphp artisan optimize on deploy
Database queries (rarely changing)Cache::remember() with TTL
Full-page or partial HTMLResponse caching middleware
Computed aggregatesScheduled command + cache store
User-specific dataCache key with user ID prefix

Authentication Package

NeedPackage
Simple login/register UIBreeze
Teams, 2FA, profile managementJetstream
Headless (API only, no UI)Fortify
API tokens for SPA/mobileSanctum
OAuth provider (social login)Socialite

Reference Index

FileContents
references/eloquent-and-data.mdEloquent relationships, scopes, observers, casts, query optimization, eager loading, migrations, factories, and API resources
references/routing-and-controllers.mdRoutes, middleware, route model binding, controllers, Form Requests, policies, rate limiting, and endpoint structure
references/frontend-and-auth.mdBlade, Livewire, Inertia, Sanctum, Breeze, Fortify, Jetstream, guards, gates, policies, and Socialite integration
references/architecture-and-operations.mdService container, providers, actions, jobs, queues, Horizon, events, listeners, cache strategy, and Laravel 11 bootstrap structure
references/testing-and-deployment.mdPest and PHPUnit, HTTP tests, factories, mocking, parallel tests, Forge, Vapor, Docker, Octane, and zero-downtime deployment

Command Palette

Search skills, docs, and navigate Tank