laravel-api

Enforce Laravel REST API design best practices for controllers, resources, and routing.

1|Updated Feb 28, 2026
One-click install
npx skills add https://github.com/sasabajic/laravel-best-practice-skills --skill laravel-api-sasabajic
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-api
Source: https://github.com/sasabajic/laravel-best-practice-skills/tree/main/laravel-api
Command: npx skills add https://github.com/sasabajic/laravel-best-practice-skills --skill laravel-api-sasabajic

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a comprehensive guide and best practices for building secure, efficient, and well-structured REST APIs using the Laravel framework, reducing common errors and improving maintainability.

Core Features & Use Cases

  • API Controller Standards: Enforces separation and naming conventions for API controllers.
  • API Resource Transformation: Guides the use of API Resources for consistent JSON output.
  • Routing Conventions: Defines best practices for API versioning, authentication grouping, and resource routing.
  • Response Formatting: Ensures consistent JSON structures and appropriate HTTP status codes.
  • Authentication: Demonstrates secure API authentication using Sanctum.
  • Filtering & Sorting: Implements patterns for efficient data filtering and sorting.
  • Rate Limiting: Configures API rate limiting to prevent abuse.
  • Error Handling: Establishes robust API error handling mechanisms.
  • Use Case: When developing a new feature that requires an API endpoint, use this Skill to ensure the endpoint adheres to all Laravel API best practices from the start.

Quick Start

Use the laravel-api skill to generate a standard API controller for managing 'Order' resources.

Frequently Asked Questions about laravel-api

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

FAQPage Schema
How do I build a REST API in Laravel using API Resources for consistent JSON output?

To build a Laravel REST API with consistent JSON output, use API Resources to transform your Eloquent models into standardized JSON structures. This ensures uniform response formatting across all endpoints while maintaining separation between database models and HTTP output.

What is the best way to implement API authentication in a Laravel backend?

The best way to implement API authentication in a Laravel backend is using Sanctum. It provides secure, lightweight token-based authentication for REST APIs without the complexity of OAuth, ensuring protected endpoints only accept valid user credentials.

How do I structure API controllers and routing conventions for versioning in Laravel?

Structure Laravel API controllers by maintaining strict separation and naming conventions. For routing, group endpoints by version and authentication middleware, using resource routing to map standard HTTP verbs to controller methods efficiently.

How do I handle filtering, sorting, and rate limiting in a Laravel REST API?

Handle filtering and sorting in a Laravel REST API by implementing specific query parameter patterns. Configure API rate limiting in your route definitions to prevent endpoint abuse and ensure consistent server performance under high request loads.

How do I establish robust error handling and HTTP status codes for Laravel API endpoints?

Establish robust Laravel API error handling by returning consistent JSON error structures with appropriate HTTP status codes. This ensures clients receive clear, actionable feedback for failed validation, missing resources, or server errors.

Does the laravel-api skill work for refactoring existing API endpoints to meet best practices?

Yes, the laravel-api skill works for refactoring existing endpoints to meet Laravel API development standards. It enforces conventions for response structure, routing, and authentication, ensuring legacy code aligns with current REST design best practices.