ekhaled/f3-cortex-model-generator
Composer 安装命令:
composer require ekhaled/f3-cortex-model-generator
包简介
Generates F3 Cortex models by reverse engineering existing database schema
README 文档
README
Generates F3 Cortex models by reverse engineering existing database schema.
Currently only supports MySQL.
Installation
Please add
"ekhaled/f3-cortex-model-generator": "1.0"
to your composer file.
Usage
Create an executable PHP file with the following contents
#!/usr/bin/env php <?php require_once(__DIR__ . '/../src/vendor/autoload.php'); $config = [ 'output' => 'path/to/output/folder/', 'DB' => array(), //DB connection params 'namespace' => 'Models\\Base', 'extends' => '\\Models\\Base', 'relationNamespace' => '\\Models\Base\\', 'template' => 'path/to/template/file', 'indentation' => array(), 'exclude' => array() ]; $generator = new \Ekhaled\Generators\MySQL\Model($config); $generator->generate();
and, just run the file from the command line.
Options
output- specifies the folder where models will be output to.DB- an array in the following format ['host' => 'host.com', 'username' => '', 'password' => '', 'dbname' => 'name_of_database',]namespace- Namespace of the generated modelsextends- if you have a base model, you can make the generated model extend that model by specifying it here.relationNamespace- Namespace of the connected classes that constitute relationships with a given model, usually it's the same asnamespacetemplate- Path to file containing a custom template, if not specified a built-in template will be used.indentation- an array that indicates what type of unit of indentation to be used on template generation followed by a starting level.
For example:['unit' => ' ', 'start_level' => 3]. This will use 2 spaces as indentation starting at 6 spaces.
This is applied to the array defined by the {{FIELDCONF}} templateexclude_views- Whether to generate models for Views too, defaults to false.exclude_connectors- Whether to generate stub models for many-to-many connector tables, defaults to false. (Sometimes you might need these models to create db tables, for example for automated tests in test databases).exclude- An array containing all tables that you would like to exclude while generating models. For example:array('migrations').
Custom templates
A typical custom template would look like:
<?php {{NAMESPACE}} class {{CLASSNAME}} {{EXTENDS}} { protected $fieldConf = [ {{FIELDCONF}} ], $table = '{{TABLENAME}}'; }
Just ensure that the placeholders are in place, and they will get replaced during model generation.
Supported placeholders are:
{{NAMESPACE}}{{CLASSNAME}}{{EXTENDS}}{{FIELDCONF}}{{TABLENAME}}
ekhaled/f3-cortex-model-generator 适用场景与选型建议
ekhaled/f3-cortex-model-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.07k 次下载、GitHub Stars 达 15, 最近一次更新时间为 2016 年 08 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mysql」 「schema」 「model」 「F3」 「fatfree」 「model-generator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ekhaled/f3-cortex-model-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ekhaled/f3-cortex-model-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ekhaled/f3-cortex-model-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Extension for Opis JSON Schema
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
EAV modeling package for Eloquent and Laravel.
serialize Symfony Forms into JSON schema
Interfaces for web resource models and services to retrieve and create them
统计信息
- 总下载量: 1.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 15
- 点击次数: 14
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-08-25