iramgutierrez / laravel-resource-api
为Laravel 5.2创建资源API:实体、仓库、管理器、验证器、控制器、迁移、表、路由和文档
1.0.26
2016-11-11 18:39 UTC
Requires
- php: >=5.5.9
- illuminate/console: 5.3.*
- illuminate/http: 5.3.*
- illuminate/support: 5.3.*
- memio/memio: ^1.0
README
完整的RESTful API资源生成器,
此包实现了层模式设计,包括
- 实体
- 控制器
- 管理器
- 验证器
- 仓库
- 迁移
- 路由
- 文档(需要安装apidocjs)
安装
将以下行添加到您的composer.json
文件中
"iramgutierrez/laravel-resource-api": "1.0.*"
运行composer update
以获取此包。
一旦Composer安装了该包,请将此行代码添加到位于您的config/app.php
文件中的providers
数组中
IramGutierrez\API\APIServiceProvider::class,
将此行代码添加到位于您的app/Console/Kernel.php
文件中的受保护的$commands
数组中
\IramGutierrez\API\ResourceAPI::class,
迁移和配置发布
运行php artisan vendor:publish
以发布此包配置和迁移。之后,您可以编辑config/resource_api.php
文件以设置生成资源的命名空间。
运行迁移以创建所需的表
php artisan migrate
用法
现在,您应该可以使用Artisan命令:create-resource-api
,可以使用如下方式使用
php artisan create-resource-api {Entity}
示例
运行
php artisan create-resource-api Test
然后,命令会询问您表名
Table name [tests]:
命名空间
Path name [API]:
路由前缀
Prefix route []:
是否生成文档
Generate documentation? (Require apidocjs) (yes/no) [yes]:
是否生成迁移文件
Generate migration? (yes/no) [yes]:
是否运行迁移
Run migration? (yes/no) [yes]:
是否在routes.php
文件中添加路由资源
Add routes resource? (yes/no) [yes]:
是否添加中间件
Middlewares or middleware groups (comma separated) []:
执行完成后,您应该可以访问以下功能路由
许可证
Laravel Resource API包在MIT许可证下发布。