laravel-api
REST and JSON API standards for modern Laravel backends. Use when designing REST endpoints, API resources, or JSON API responses in Laravel.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Laravel API
Priority: P1 (HIGH)
Structure
app/
└── Http/
├── Resources/ # Data transformation
└── Controllers/
└── Api/ # API specific logic
Implementation Guidelines
- API Resources: Always use Resources/Collections for JSON formatting.
-
RESTful Actions: Follow standard naming (
index,store,update). - Auth: Use Sanctum for SPAs/Mobile or Passport for OAuth2.
- Status Codes: Return appropriate HTTP codes (201 Created, 422 Unprocessable).
-
Versioning: Prefix routes with version tags (e.g.,
api/v1/...). -
Rate Limiting: Configure
RateLimiterto protect public endpoints.
Anti-Patterns
- Raw Models: No raw model returns: Information leakage risk.
- Manual JSON: No response()->create(): Use API Resources.
- Session Auth: No sessions for APIs: Use Tokens (Sanctum).
- Hardcoded URLs: No static links in JSON: Use HATEOAS or route names.
References
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-03-11
- 索引更新时间
- 2026-03-11
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!