mrcorex/laravel-model-generator
Composer 安装命令:
composer require mrcorex/laravel-model-generator
包简介
Auto-generate models for a Laravel 5 project.
关键字:
README 文档
README
Auto-generate models for a Laravel 5 project.
Note: it is recommended to abandon this package and use corex/lmodel instead. It is more up-to-date and uses doctrine/dbal instead of native sql + other advantages. There are a few changes in configuration but easy to convert config to corex/lmodel.
You can continue to use this package. I will do my best to support future versions.
Only MySQL will be supported.
Connects to your existing database and auto-generates models based on existing schema.
- Support for multiple dababases.
- Support for magic properties.
- Support for custom methods.
- Support for guarded fields.
- Support for "extends".
- Support for extra column-attributes after magic properties.
- Support for building constants in model.
- Support for multiple "uses".
- Support for custom "indent".
Installation
Run "composer require mrcorex/laravel-model-generator".
Add a configuration-file called corex and add following code to it. Modify it to suit your needs.
return [ 'laravel-model-generator' => [ 'path' => base_path('app/Models'), 'namespace' => 'App\Models', 'databaseSubDirectory' => true, 'extends' => '', 'indent' => "\t", 'uses' => [], 'const' => [ '{connection}' => [ '{table}' => [ 'id' => '{id}', 'name' => '{name}', 'prefix' => '{prefix}', 'suffix' => '{suffix}', 'replace' => [ 'XXXX' => 'YYYY', ] ] ] ] ] ];
Settings:
- path - where models are saved.
- namespace - namespace of models.
- databaseSubDirectory - true/false if name of database-connection should be applied to namespace/directory. Name will automatically be converted to PascalCase.
- extends - (optional) class to extend instead of "Illuminate\Database\Eloquent\Model". Default ''.
- indent - (optional) String to use as indent i.e. "\t". Default 4 spaces.
- uses - (optional) List of use's. Warning: it does not clean up old uses, if you change "extends" after model initially was created.
- const - (optional) This section is used to specify connections and tables which should contains constants from content of table.
- {connection} - (optional) Name of connection.
- {table} - (optional) Name of table.
- {id} - (required) Name of field to get id from used in constant as value.
- {name} - (required) Name of field to get name of constant.
- {prefix} - (optional) Prefix to add to each name of constant.
- {suffix} - (optional) Suffix to add to each name of constant.
- replace - (optional) Values to replace in name of constant.
To register it and make sure you have this option available for development only, add following code to AppServiceProviders@register.
public function register() { if ($this->app->environment() == 'local') { $this->app->register('CoRex\Generator\ModelGeneratorProvider'); } }
Help
php artisan help make:models
Arguments:
- connection: Name of connection to generate models from. It will be added to namespace/path for separation of models. It is possible to disable this.
- tables: Comma separated table names to generate. Specify "." to generate all.
Options:
- guarded: Comma separated list of guarded fields.
mrcorex/laravel-model-generator 适用场景与选型建议
mrcorex/laravel-model-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.18k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 04 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「model」 「laravel」 「magic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mrcorex/laravel-model-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mrcorex/laravel-model-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mrcorex/laravel-model-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
Interfaces for web resource models and services to retrieve and create them
Laravel 5 - Repositories to the database layer
This package provides an Address Model, Migration and Factory. It also provides the traits HasBillingAddres and HasPublicAddress
The YADM migrations
统计信息
- 总下载量: 2.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-06