laravel-api
БесплатноБез исполняемых скриптовНе проверенBuild REST endpoints with API Resources, Sanctum authentication, and versioned route groups in Laravel. Use when creating JsonResource classes, adding…
от HoangNguyen0403★ 598 звёзд на GitHubОб этом скилле
Laravel API
Priority: P1 (HIGH)
Workflow: Create New API Endpoint
- Generate resource —
php artisan make:resource UserResource. - Define toArray() — Specify exact output fields; never return raw models.
- Add route — Register in
routes/api.phpwith version prefix and throttle middleware. - Secure with Sanctum — Apply
auth:sanctummiddleware to protected routes. - Return proper status codes — 201 for Created, 422 for Validation, 204 for No Content.
API Resource Example
See implementation examples for complete API Resource with collection usage.
Implementation Guidelines
API Resources & Transformation
- API Resources: Always use
ApiResourceclasses extendingJsonResourcefor data transformation. - Collections: Use
UserResource::collection($users)for lists. Never useresponse()->json($model)or return raw models directly. - Data Definition: Implement
toArray($request)to define specific output fields and prevent sensitive data leakage. - Generation: Use
php artisan make:resource UserResourceto scaffold new resources.
Authentication & Security
- Sanctum: Use
auth:sanctummiddleware inroutes/api.phpfor SPAs or mobile app authentication. - Traits: Add
HasApiTokenstrait to yourUsermodel to enable token-based authentication. - Token Management: Issue tokens using
$user->createToken('token-name')->plainTextToken. - OAuth2: Use Passport only if standard OAuth2 flows or client grants required.
Routing & Performance
- Versioning: Group routes with
Route::prefix('v1')->group(...)and use versioned namespaces (e.g.,App\Http\Controllers\Api\V1). - Rate Limiting: Define
RateLimiter::for('api', ...)usingLimit::perMinute(60)inAppServiceProvider. - Middleware: Apply
throttle:apimiddleware to route groups inroutes/api.php. - Status Codes: Return 201 for Created, 422 for Validation errors, and 204 for No Content.
Anti-Patterns
- No raw model returns: Use API Resources; prevents data leakage.
- No
response()->json(): Use API Resource classes instead. - No session auth for APIs: Use Sanctum or Passport tokens.
- No static URLs in JSON: Use route names or HATEOAS links.
References
Установить laravel-api в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл laravel-api?
Build REST endpoints with API Resources, Sanctum authentication, and versioned route groups in Laravel. Use when creating JsonResource classes, adding token-based auth, or defining rate-limited API routes.
Как установить скилл laravel-api?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл laravel-api запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic