smart-php/laravel-cred-api-builder
Composer 安装命令:
composer require smart-php/laravel-cred-api-builder
包简介
A package for Laravel to build CRUD REST APIs.
README 文档
README
Laravel CRED API Builder is a Laravel package that simplifies the process of creating APIs for basic CRUD (Create, Read, Update, Delete) operations. With a single command, it generates all the necessary files for CRED functionality, including:
- Controller File
- Request File
- Resource File
- Service File
Features
- Single Command API Generation: Generate all required files with one simple command.
- Model Optionality: Specify a model name or let the package use the class name as the default model name.
- RESTful Endpoints: Automatically creates endpoints for common CRUD operations.
- Pagination: Includes Laravel's pagination for listing records.
Endpoints Created
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/<name> |
Get a paginated list of all records. |
POST |
/api/<name> |
Create a new object in the database. |
GET |
/api/<name>/<id> |
Retrieve object details by ID. |
PUT |
/api/<name>/<id> |
Update an existing record by ID. |
DELETE |
/api/<name>/<id> |
Delete a record by ID. |
Installation
Follow these steps to install the Laravel CRED API Builder package:
-
Require the package via Composer:
composer require smart-php/laravel-cred-api-builder --dev
Usage
Run the following Artisan command to generate the CRED API files:
php artisan make:cred-api <name> <model-name>
<name>: The name of the API resource (e.g.,Post).<model-name>(optional): The name of the model to associate with the API. If not provided, the class name will be used as the model name.
Example Command
php artisan make:cred-api Post PostModel
This will generate all required files for the Post API and use PostModel as the associated model.
Generated Files
- Controller: Handles the business logic and API routes.
- Request: Validates incoming data for creating and updating records.
- Resource: Formats the API response data.
- Service: Encapsulates reusable business logic.
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
smart-php/laravel-cred-api-builder 适用场景与选型建议
smart-php/laravel-cred-api-builder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 01 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 smart-php/laravel-cred-api-builder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smart-php/laravel-cred-api-builder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-13