ekhaled/f3-cortex-model-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ekhaled/f3-cortex-model-generator

最新稳定版本:1.8

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 models
  • extends - 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 as namespace
  • template - 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}} template
  • exclude_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}}

统计信息

  • 总下载量: 1.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固