What problem does it solve?
This Skill unit helps developers streamline Laravel controllers by promoting thin, RESTful, and domain-agnostic code, enhancing application structure and maintainability.
Core Features & Use Cases
- Controller Structure: Guidelines for controller naming conventions and RESTful method usage.
- Web vs API Layer: Differentiation between web layer controllers (HTML forms, Blade views) and public API controllers (JSON endpoints).
- Query Objects: Integration with Spatie Query Builder for filtering, sorting, and includes in API endpoints.
- Authorization: Best practices for controller-based authorization.
- Route Model Binding: Simplified model handling with route model binding.
- Controller Testing: Writing feature tests for controllers with Pest and Laravel's testing framework.
- Avoiding Common Mistakes: Tips on preventing domain logic in controllers and avoiding unnecessary database queries.
Quick Start
To optimize your Laravel controllers, follow the guidelines provided in the SKILL.md file for RESTful method naming, separation of concerns, and using query objects for complex filtering and sorting.