plugins/laravel-expert/skills/laravel-architecture/SKILL.md
Design Laravel app architecture with services, repositories, actions, and clean code patterns. Use when structuring projects, creating services, implementing DI, or organizing code layers.
npx skillsauth add fusengine/agents laravel-architectureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Before ANY implementation, use TeamCreate to spawn 3 agents:
After implementation, run fuse-ai-pilot:sniper for validation.
Laravel architecture focuses on clean separation of concerns, dependency injection, and maintainable code organization. This skill covers everything from project structure to production deployment.
app/
├── Actions/ # Single-purpose action classes
├── Contracts/ # Interfaces (DI)
├── DTOs/ # Data transfer objects
├── Enums/ # PHP 8.1+ enums
├── Events/ # Domain events
├── Http/
│ ├── Controllers/ # Thin controllers
│ ├── Middleware/ # Request filters
│ ├── Requests/ # Form validation
│ └── Resources/ # API transformations
├── Jobs/ # Queued jobs
├── Listeners/ # Event handlers
├── Models/ # Eloquent models only
├── Policies/ # Authorization
├── Providers/ # Service registration
├── Repositories/ # Data access layer
└── Services/ # Business logic
| Reference | When to Use | |-----------|-------------| | container.md | Dependency injection, binding, resolution | | providers.md | Service registration, bootstrapping | | facades.md | Static proxies, real-time facades | | contracts.md | Interfaces, loose coupling | | structure.md | Directory organization | | lifecycle.md | Request handling flow |
| Reference | When to Use | |-----------|-------------| | configuration.md | Environment, config files | | installation.md | New project setup | | upgrade.md | Version upgrades, breaking changes | | releases.md | Release notes, versioning |
| Reference | When to Use | |-----------|-------------| | sail.md | Docker development | | valet.md | macOS native development | | homestead.md | Vagrant (legacy) | | octane.md | High-performance servers |
| Reference | When to Use | |-----------|-------------| | artisan.md | CLI commands, custom commands | | helpers.md | Global helper functions | | filesystem.md | File storage, S3, local | | processes.md | Shell command execution | | context.md | Request-scoped data sharing |
| Reference | When to Use | |-----------|-------------| | pennant.md | Feature flags | | mcp.md | Model Context Protocol | | concurrency.md | Parallel execution |
| Reference | When to Use | |-----------|-------------| | deployment.md | Production deployment | | envoy.md | SSH task automation | | logging.md | Log channels, formatting | | errors.md | Exception handling | | packages.md | Creating packages |
| Template | Purpose | |----------|---------| | UserService.php.md | Service + repository pattern | | AppServiceProvider.php.md | DI bindings, bootstrapping | | ArtisanCommand.php.md | CLI commands, signatures, I/O | | McpServer.php.md | MCP servers, tools, resources, prompts | | PennantFeature.php.md | Feature flags, A/B testing | | Envoy.blade.php.md | SSH deployment automation | | sail-config.md | Docker Sail configuration | | octane-config.md | FrankenPHP, Swoole, RoadRunner |
| Feature | Reference | Priority | |---------|-----------|----------| | Service Container | container.md | High | | Service Providers | providers.md | High | | Directory Structure | structure.md | High | | Configuration | configuration.md | High | | Installation | installation.md | High | | Octane (Performance) | octane.md | High | | Sail (Docker) | sail.md | High | | Artisan CLI | artisan.md | Medium | | Deployment | deployment.md | Medium | | Envoy (SSH) | envoy.md | Medium | | Facades | facades.md | Medium | | Contracts | contracts.md | Medium | | Valet (macOS) | valet.md | Medium | | Upgrade Guide | upgrade.md | Medium | | Logging | logging.md | Medium | | Errors | errors.md | Medium | | Lifecycle | lifecycle.md | Medium | | Filesystem | filesystem.md | Medium | | Helpers | helpers.md | Low | | Pennant (Flags) | pennant.md | Low | | Context | context.md | Low | | Processes | processes.md | Low | | Concurrency | concurrency.md | Low | | MCP | mcp.md | Low | | Packages | packages.md | Low | | Releases | releases.md | Low | | Homestead | homestead.md | Low |
public function __construct(
private readonly UserServiceInterface $userService,
) {}
public function register(): void
{
$this->app->bind(UserServiceInterface::class, UserService::class);
$this->app->singleton(CacheService::class);
}
php artisan make:provider CustomServiceProvider
php artisan make:command ProcessOrders
$debug = env('APP_DEBUG', false);
$config = config('app.name');
Nouvelle méthode pour rafraîchir le TTL sans recalculer la valeur.
Cache::touch('user:123', now()->addHour());
Cache::touch(['user:123', 'user:456'], 3600);
Voir [[laravel-queues]] pour le routing déclaratif par job (connexion/queue cible via configuration plutôt que sur chaque job).
new Model() dans boot() → LogicExceptionLaravel 13 jette une LogicException si vous instanciez un modèle Eloquent dans register() d'un ServiceProvider (container pas prêt). Utiliser boot() ou un listener.
| Sujet | Avant (12) | Après (13) |
|-------|-----------|------------|
| PHP minimum | 8.2 | 8.3 |
| PHPUnit | 11 | 12 |
| Pest | 3 | 4 |
| CSRF | VerifyCsrfToken | PreventRequestForgery (origin-aware) |
| Cache prefix | underscore | hyphens par défaut (configurer CACHE_PREFIX, REDIS_PREFIX, SESSION_COOKIE pour rétro-compat) |
| Beanstalk | pheanstalk 7.x | pheanstalk 8.0+ |
| Symfony | 7.x | 7.4 / 8.0 |
| Model boot | toléré | new Model() → LogicException |
| Config | — | nouveau serializable_classes (allowlist hardening) |
# Rétro-compat cache prefixes pour upgrade depuis L12
CACHE_PREFIX=laravel_cache_
REDIS_PREFIX=laravel_database_
SESSION_COOKIE=laravel_session
// config/app.php — durcissement deserialize
'serializable_classes' => [
App\DTO\PaymentDto::class,
App\DTO\OrderDto::class,
],
final readonly class pour DTOs et Value Objects (PHP 8.3+)interface (DI inversion)Context::add() pour propager metadata entre jobs/requêtesserializable_classes en productionapp(Contract::class) sur App::make() (typage strict)register() (→ LogicException L13)base_path(), storage_path())new ConcreteClass()development
Use when optimizing entity-based / semantic SEO 2026. Covers entity maps, Google Knowledge Graph resolution, salience scoring, passage-level ranking, about/sameAs/knowsAbout schema, Cloud Natural Language API validation.
development
Use when running SEO, GEO, schema, Core Web Vitals, sitemap, hreflang, E-E-A-T, AI Overviews, technical SEO, or structured data tasks. Covers full-site audits, single-page analysis, schema markup, content quality, AI search optimization, local SEO, sitemap/robots, internal linking, semantic clustering, and search experience.
development
Use when optimizing search experience (SXO). Covers intent matching, user personas, user stories, page-type analysis, dwell time, scroll depth, pogo-sticking prevention.
development
Use when optimizing local SEO. Covers Google Business Profile, NAP consistency, citations, reviews acquisition, Local Pack ranking, location pages, LocalBusiness schema.