rohinigeeks/laravel-sorcery
Composer 安装命令:
composer require rohinigeeks/laravel-sorcery
包简介
Laravel API/Scaffold/CRUD Generator from just one command with including Controller, Repository, Model, Migrations, routes.php update.
README 文档
README
Laravel Sorcery generates boilerplate code for a Laravel Web App from the MySQL Schema
This command Generator generates following things:
- Migration File
- Model
- Repository (optional)
- Controller
- View
- index.blade.php
- show.blade.php
- create.blade.php
- edit.blade.php
- fields.blade.php
- updates routes.php
Here is the full documentation.
Steps to Get Started
-
Add this package to your composer.json:
"require": { "rohinigeeks/laravel-sorcery": "dev-master" } -
Run composer update
composer update -
Add the ServiceProviders to the providers array in
config/app.php.
As we are using these two packages illuminate/html & laracasts/flash as a dependency.
so we need to add those ServiceProviders as well.'Illuminate\View\ViewServiceProvider', 'Illuminate\Html\HtmlServiceProvider', 'Laracasts\Flash\FlashServiceProvider' 'Rohinigeeks\Generator\GeneratorServiceProvider'
Also for convenience, add these facades in alias array in config/app.php.
'Form' => 'Illuminate\Html\FormFacade',
'HTML' => 'Illuminate\Html\HtmlFacade',
'Flash' => 'Laracasts\Flash\Flash'
-
Publish generator.php
php artisan vendor:publish --provider='Rohinigeeks\Generator\GeneratorServiceProvider' -
Fire the artisan command to generate API for Model, or to generate scaffold with views for web applications
php artisan rohinigeeks.generator:api ModelName php artisan rohinigeeks.generator:scaffold ModelNamee.g.
php artisan rohinigeeks.generator:api Project php artisan rohinigeeks.generator:api Post php artisan rohinigeeks.generator:scaffold Project php artisan rohinigeeks.generator:scaffold Post -
And You are ready to go. :)
Documentation
Generator Config file
Config file (config/generator.php) contains path for all generated files
path_migration - Path where Migration file to ge generated
path_model - Path where Model file to ge generated
path_repository - Path where Repository file to ge generated
path_controller - Path where Controller file to ge generated
path_views - Path where views will be created
path_request - Path where request file will be created
path_routes - Path of routes.php (if you are using any custom routes file)
namespace_model - Namespace of Model
namespace_repository - Namespace of Repository
namespace_controller - Namespace of Controller
namespace_request - Namespace for Request
Field Input
Here is the input for the fields by which you can specify Input.
fieldName:fieldType,options:fieldOptions
e.g.,
email:string:unique
email:string:unique,default('me@mitul.me')
title:string,100
price:flat,8,4
Parameters will be in the same sequence as Blueprint class function for all types.
Option will be printed as it is given in input except unique & primary.
API Response Structure
Remember: This response structure is based on the most of my API response structure, you can change it to your API response after file generation in controller.
Success
{
"flag":true,
"message":"success message",
"data":{}
}
data can be anything as per response.
Failure
{
"flag":false,
"message":"failure message",
"code": 0
"data":{}
}
data will be optional. And code will be error code.
Generated Views
While generating scaffold, all views are created with basic CRUD functionality. (currently delete is not working)
Views will be created in resources/views/modelName folder,
index.blade.php - Main Index file for listing records
create.blade.php - To insert a new record
edit.blade.php - To edit a record
fields.blade.php - Common file of all model fields, which will be used create and edit record
show.blade.php - To display a record
Credits
This API Generator was forked from laravel-api-generator created by
- Jamison Valenta
- Mitul Golakiya.
- [Bernhard Breytenbach] (https://github.com/Xethron)
Screenshots
Command Execution
![Image of Command Execution] (http://drive.google.com/uc?export=view&id=0B5kWGBdVjC7RbTRvTEswQ0tfOEU)
Generated Files & routes.php
![Image of Generated Files] (http://drive.google.com/uc?export=view&id=0B5kWGBdVjC7RZ1VMcXlsM1Z2MDg)
Migration File
![Image of Migration File] (http://drive.google.com/uc?export=view&id=0B5kWGBdVjC7RMWtnN1RxUzdmTUE)
Model File
![Image of Model File] (http://drive.google.com/uc?export=view&id=0B5kWGBdVjC7RRUJfdHE4MVRaeXM)
Repository File
![Image of Repository File] (http://drive.google.com/uc?export=view&id=0B5kWGBdVjC7ROUdNVTVORm5nQ1E)
Controller File
![Image of Controller File] (http://drive.google.com/uc?export=view&id=0B5kWGBdVjC7RREVacVlOZDhxNDQ)
View Files
![Image of View Files] (http://drive.google.com/uc?export=view&id=0B5kWGBdVjC7RQW5FOXExOFhEbms)
rohinigeeks/laravel-sorcery 适用场景与选型建议
rohinigeeks/laravel-sorcery 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 135 次下载、GitHub Stars 达 11, 最近一次更新时间为 2015 年 03 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「api」 「migration」 「model」 「crud」 「scaffold」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rohinigeeks/laravel-sorcery 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rohinigeeks/laravel-sorcery 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rohinigeeks/laravel-sorcery 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Lets you add foreign keys in a swift! Foreign key adder in laravel migration.
A PSR-7 compatible library for making CRUD API endpoints
Manage PostgreSQL schemas in Laravel applications
Bitrix db migration core libs
The YADM migrations
统计信息
- 总下载量: 135
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-18