nicoaudy/laravelmanthra
Composer 安装命令:
composer require nicoaudy/laravelmanthra
包简介
Laravel Manthra For Lazy Developer
README 文档
README
Installation
Via Composer
$ composer require nicoaudy/laravelmanthra dev-master
Install laravelcollective/html form helper packages for if you haven't installed yet.
$ composer require laravelcollective/html
$ composer dump-autoload
Publish vendor files of this package.
$ php artisan vendor:publish
Generator GUI
If you want to generate using gui, manthra will provide you with generator gui you can view in /manthra.
You can modified your /manthra to append middleware with forcing default route to your custom route.
// manthra controller $manthraNamespace = 'NicoAudy\LaravelManthra\Http\Controllers\ManthraController@index'; // your custom route Route::get('/manthra', $manthraNamespace)->middleware('auth');
Commands
Complete (web and api)
Generate crud scaffold web and api you may use this command, for example :
php artisan manthra:complete Cat --fields="name#string;age#integer; type#select#options=persian,maine coon,bengal; is_male#boolean" --view-path=pet --controller-namespace=Pet --route-group=pet --model-namespace=Models
Web
Generate crud scaffold web only you may use this command, for example :
php artisan manthra:web Cat --fields="name#string;age#integer; type#select#options=persian,maine coon,bengal; is_male#boolean" --view-path=pet --controller-namespace=Pet --route-group=pet --model-namespace=Models
Api
Generate crud scaffold api only you may use this command, the difference between web and api just (--view-path=) flag, for example :
php artisan manthra:api Cat --fields="name#string;age#integer; type#select#options=persian,maine coon,bengal; is_male#boolean" --controller-namespace=Pet --route-group=pet --model-namespace=Models
Options:
| Option | Description |
|---|---|
--fields |
Fields name for the form & migration. e.g. --fields="title#string; content#text; category#select#options=technology,tips,health; user_id#integer#unsigned" |
--route |
Include Crud route to routes.php? yes or no |
--pk |
The name of the primary key |
--view-path |
The name of the view path |
--controller-namespace |
The namespace of the controller - sub directories will be created |
--model-namespace |
The namespace that the model will be placed in - directories will be created |
--route-group |
Prefix of the route group |
--pagination |
The amount of models per page for index pages |
--indexes |
The fields to add an index to. append "#unique" to a field name to add a unique index. Create composite fields by separating fieldnames with a pipe (``` --indexes="title,field1 |
--foreign-keys |
Any foreign keys for the table. e.g. --foreign-keys="user_id#id#users#cascade" where user_id is the column name, id is the name of the field on the foreign table, users is the name of the foreign table, and cascade is the operation 'ON DELETE' together with 'ON UPDATE' |
--validations |
Validation rules for the form "col_name#rules_set" e.g. ``` "title#min:10 |
--relationships |
The relationships for the model. e.g. --relationships="comments#hasMany#App\Comment" in the format |
--localize |
Allow to localize. e.g. localize=yes |
--locales |
Locales language type. e.g. locals=en |
Other commands (optional):
For controller:
- Standard Version
php artisan manthra:controller PostsController --crud-name=posts --model-name=Post --view-path="directory" --route-group=admin
- API Version
php artisan manthra:api-controller PostsController --crud-name=posts --model-name=Post --route-group=admin
Controller's Options:
| Option | Description |
|---|---|
--crud-name |
The name of the crud. e.g. --crud-name="post" |
--model-name |
The name of the model. e.g. --model-name="Post" |
--model-namespace |
The namespace of the model. e.g. --model-namespace="Custom\Namespace\Post" |
--controller-namespace |
The namespace of the controller. e.g. --controller-namespace="Http\Controllers\Client" |
--view-path |
The name of the view path |
--fields |
Fields name for the form & migration. e.g. --fields="title#string; content#text; category#select#options=technology,tips,health; user_id#integer#unsigned" |
--validations |
Validation rules for the form "col_name#rules_set" e.g. ``` "title#min:10 |
--route-group |
Prefix of the route group |
--pagination |
The amount of models per page for index pages |
--force |
Overwrite already existing controller. |
For model:
php artisan manthra:model Post --fillable="['title', 'body']"
For migration:
php artisan manthra:migration posts --schema="title#string; body#text"
For view:
php artisan manthra:view posts --fields="title#string; body#text" --view-path="directory" --route-group=admin
By default, the generator will attempt to append the crud route to your Route file. If you don't want the route added, you can use this option --route=no.
After creating all resources, run migrate command. If necessary, include the route for your crud as well.
php artisan migrate
If you chose not to add the crud route in automatically (see above), you will need to include the route manually.
Route::resource('posts', 'PostsController');
Supported Field Types
These fields are supported for migration and view's form:
Form Field Types:
- text
- textarea
- password
- number
- date
- datetime
- time
- radio
- select
- file
Migration Field Types:
- string
- char
- varchar
- date
- datetime
- time
- timestamp
- text
- mediumtext
- longtext
- json
- jsonb
- binary
- integer
- bigint
- mediumint
- tinyint
- smallint
- boolean
- decimal
- double
- float
- enum
Custom Generator's Stub Template
You can customize the generator's stub files/templates to achieve your need.
-
Make sure you've published package's assets.
php artisan vendor:publish --provider="NicoAudy\LaravelManthra\LaravelManthraServiceProvider" -
Turn on custom_template support on config/laravelmanthra.php
'custom_template' => true, -
From the directory resources/manthra/stubs/ you can modify or customize the stub files.
-
On config/laravelmanthra.php you can add new stubs and choose which values are passed
Change log
Please see the changelog for more information on what has changed recently.
Contributing
Please see contributing.md for details and a todolist.
Credits
License
license. Please see the license file for more information.
nicoaudy/laravelmanthra 适用场景与选型建议
nicoaudy/laravelmanthra 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.96k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2019 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「crud」 「laravel」 「crud generator」 「laravel crud generator」 「LaravelManthra」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nicoaudy/laravelmanthra 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nicoaudy/laravelmanthra 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nicoaudy/laravelmanthra 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Gii Generator for double model generation
A PSR-7 compatible library for making CRUD API endpoints
Admin panel generator for Laravel 8 and based on Vuetify Admin, a separate SPA admin framework running on top of REST APIs.
Collection of tools to use the full power of the Enyalius framework
Laravel Admin CRUD Generator
统计信息
- 总下载量: 1.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 30
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-09

