laravel-controllers

Write thin RESTful Laravel 8.5 controllers with query objects and testing guidelines.

1|Updated May 24, 2026
One-click install
npx skills add https://github.com/PTKDrake/FIT-vmu --skill laravel-controllers-ptkdrake
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-controllers
Source: https://github.com/PTKDrake/FIT-vmu/tree/main/.agents/skills/laravel-controllers
Command: npx skills add https://github.com/PTKDrake/FIT-vmu --skill laravel-controllers-ptkdrake

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires spatie/query-builder, and includes scripts (resource) and references (resource) components.

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.

Frequently Asked Questions about laravel-controllers

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I keep domain logic out of Laravel controllers?

Thin Laravel controllers isolate HTTP layer concerns like request handling and authorization, delegating business logic elsewhere. This Skill provides guidelines for RESTful method naming and avoiding domain logic to enhance application maintainability.

What is the best way to structure web vs API controllers in Laravel?

Structuring web vs API controllers in Laravel involves differentiating layers: web controllers handle HTML forms and Blade views, while API controllers serve JSON endpoints. This separation ensures distinct handling of responses and request formats.

How do I use Spatie Query Builder for filtering in Laravel API endpoints?

Spatie Query Builder integrates into Laravel API endpoints via query objects to handle filtering, sorting, and includes. This approach maintains thin controllers by extracting complex data querying logic out of the controller methods.

Do I need Laravel 8.5 to implement these RESTful controller patterns?

Yes, implementing these specific RESTful controller patterns requires Laravel 8.5 or higher. The guidelines are tailored for this version's features and require the Spatie Query Builder package for query object functionality.

How do I write feature tests for Laravel controllers with Pest?

Writing feature tests for Laravel controllers with Pest involves testing HTTP responses and RESTful methods directly. The guidelines cover best practices for controller testing using Laravel's testing framework alongside Pest.