denis-kisel/constructor
Composer 安装命令:
composer require denis-kisel/constructor
包简介
:Ready solution for generate models with laravel-admin controllers
关键字:
README 文档
README
This is package for generate migrations with models and/or Laravel Admin controllers by patterns
Dependence
- For use Laravel Admin controllers need to install this package
- For use Laravel Translatable need to install this package
Installation
Via Composer
$ composer require denis-kisel/constructor
Usage
Create Model With Empty Migration
Command: construct:model ModelName
Example
$ php artisan construct:model App\\Models\\Post
Output
- Model:
App\Models\Post - Migration:
Schema::create('posts', function (Blueprint $table) { $table->bigIncrements('id'); $table->timestamps(); });
Create Model With Fields
Command: construct:model ModelName [options]
Option: {--fields=}
Field signature: name:type:length{extraMethod:paramValue}
Multi fields and extra methods must separate by comma ,
Example
$ php artisan construct:model App\\Models\\Post --fields=name:string:50,description:text{nullable},sort:integer{default:0},is_active:boolean{default:1}
Output
- Model:
App\Models\Post - Migration:
Schema::create('posts', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name', 50); $table->text('description')->nullable(); $table->integer('sort')->default(0); $table->boolean('is_active')->default(1); $table->timestamps(); });
Create Model With Bind To Locale(Translation)
See Translatable Doc
Command: construct:modelt ModelName [options]
Option: {--fields=}
Field signature: name:type:length{extraMethod:paramValue}[t]
Param [t] is optional and denotes translation field
Multi fields and extra methods must separate by comma ,
Example
$ php artisan construct:modelt App\\Models\\Post --fields=name:string:50[t],description:text{nullable}[t],sort:integer{default:0},is_active:boolean{default:1}
Output
- Models:
App\Models\Post,App\Models\PostTranslation - Migrations:
// For Post Schema::create('posts', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('sort')->default('0'); $table->boolean('is_active')->default('1'); $table->timestamps(); }); // For PostTranslation Schema::create('post_translations', function (Blueprint $table) { $table->bigIncrements('id'); $table->integer('post_id')->unsigned(); $table->string('locale')->index(); $table->string('name', 50); $table->text('description')->nullable(); $table->unique(['post_id','locale']); $table->timestamps(); });
Create Model With Basic Page Fields
Command: construct:page ModelName [options]
Example
$ php artisan construct:page App\\Models\\Post
Output
- Model:
App\Models\Post - Migration:
Schema::create('pages', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('code')->nullable(); $table->string('slug')->nullable(); $table->string('name'); $table->text('description')->nullable(); $table->string('title')->nullable(); $table->string('h1')->nullable(); $table->text('keywords')->nullable(); $table->text('meta_description')->nullable(); $table->integer('sort')->default('0'); $table->boolean('is_active')->default('1'); $table->timestamps(); });
Create Laravel-Admin Controller
See Laravel-Admin Doc
Command: construct:admin ModelName {--fields=}
Field signature: name:type:length{extraMethod:paramValue}
Multi fields and extra methods must separate by comma ,
Example
$ php artisan construct:admin App\\Models\\Post --fields=name:string:50,description:text{nullable},sort:integer{default:0},is_active:boolean{default:1}
Output
- Admin Controller:
App\Admin\Controllers\PostController - Contains:
// Grid protected function grid() { $grid = new Grid(new Post); $grid->model()->orderBy('created_at', 'desc'); $grid->id(__('admin.id')); $grid->name( __('admin.name'))->editable('text'); $grid->description( __('admin.description'))->editable('text'); $grid->sort( __('admin.sort'))->editable('text'); $grid->is_active( __('admin.is_active'))->editable('select', ActiveHelper::editable()); $grid->created_at(__('admin.created_at')); $grid->updated_at(__('admin.updated_at')); $grid->actions(function ($actions) { $actions->disableView(); }); return $grid; } // Form protected function form() { $form = new Form(new Post); $form->text('name', __('admin.name'))->required(); $form->ckeditor('description', __('admin.description')); $form->number('sort', __('admin.sort'))->default('0')->required(); $form->switch('is_active', __('admin.is_active'))->default('1')->required(); return $form; }
Options
| Option | Description |
|---|---|
{--fields=} |
Create model with fields |
{--pattern_path=} |
Path to file with custom fields by pattern |
{--i} |
Ignore exists model or controller |
{--m} |
Run migration |
{--a} |
Create model with laravel-admin controller |
Create Model With Fields
Option: {--fields=}
Field signature: name:type:length{extraMethod:paramValue}[t]
Param [t] is optional and denotes translation field
Multi fields and extra methods must separate by comma ,
Example
$ php artisan construct:model App\\Models\\Post --fields=name:string:50[t],description:text{nullable}[t],sort:integer{default:0},is_active:boolean{default:1}
Run Migration
Option: {--m} (migration)
Example
$ php artisan construct:model App\\Models\\Post --fields=name:string:50 --m
Overwrite Exists Model Or/And Controller
Option: {--i} (ignore)
Example
$ php artisan construct:model App\\Models\\Post --fields=name:string:50 --i
Create Model With Laravel-Admin Controller
Option: {--a} (admin)
Example
$ php artisan construct:model App\\Models\\Post --fields=name:string:50 --a
Commands
| Command | Description |
|---|---|
construct:model [options] |
Create Model |
construct:modelt [options] |
Create Translatable Model (Bind With Locale) |
construct:page [options] |
Create Model With Basics Page Fields: id, code, slug, name, description, title, h1, keywords, meta_description, sort, is_active, timestamps |
construct:paget [options] |
Create Model With Basics Page Fields(Bind With Locale). Page Fields: id, sort, is_active, timestamps. PageTranslation Fields: code, slug, name, description, title, h1, keywords, meta_description |
construct:admin [options] |
Create Laravel Admin Controller |
construct:admint [options] |
Create Translatable Laravel Admin Controller(Bind With Locale) |
construct:admin_page [options] |
Create Laravel Admin Controller With Basics Page Fields. Basic Fields: See construct:page |
install:locale [options] |
Create Locale Model With Laravel Admin Controller. Example: $ php artisan install:locale --a --m |
License
This package is open-sourced software licensed under the MIT license
Contact
Developer: Denis Kisel
- Email: denis.kisel92@gmail.com
- Skype: live:denis.kisel92
denis-kisel/constructor 适用场景与选型建议
denis-kisel/constructor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 69 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 05 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「constructor」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 denis-kisel/constructor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 denis-kisel/constructor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 denis-kisel/constructor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The array-like constructor of XML document structure.
Collection of traits to ease Enum manipulation in PHP
The dependency injection container based on PSR-11: Container interface.
PSR-11 Container for Dependency Injection (auto-wiring, attributes, factories, closures, array access)
PHP Creatable Objects is a PHP library that auto-wires an object's create method to its constructor regardless of visibility.
统计信息
- 总下载量: 69
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-09