定制 dodo-it/dibi-entity-generator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

dodo-it/dibi-entity-generator

最新稳定版本:2.1.2

Composer 安装命令:

composer require dodo-it/dibi-entity-generator

包简介

Entity generator from database for dibi

README 文档

README

Highly configurable typed entity generator from database. It can generate entities for whole database, table/view and from queries.

This is dibi/nette bridge for https://github.com/dodo-it/entity-generator/

Latest Stable Version Total Downloads License

Installation

$ composer require dodo-it/dibi-entity-generator

Registration

  extensions:
    entityGenerator: DodoIt\DibiEntityGenerator\DI\DibiEntityGeneratorExtension

Configuration

example:

entityGenerator:
    path: %appDir%/Model/Entity
    namespace: App\Model\Entity
    extends: App\Model\Entities\BaseEntity
    generateGetters: false
    generateSetters: false
    extends: DodoIt\EntityGenerator\Entity
    propertyVisibility: 'public'

You can see list of all options and their default values in: https://github.com/dodo-it/entity-generator/blob/master/src/Generator/Config.php

Usage

Abstract entity class

First create your BaseEntity class which all entities will extends and set option extends to that class in your configuration. As a starting point you can just Use Dibi\Row and set to only generate phpdoc comments that way nothing will change but you will have full autocomplete in your queries. Better scenario would be to generate getters and setters which then can have return typehints...

Example code in repository

public function getById(int $id): ArticleEntity
{
		return $this->db->select('*')->from('articles')->where('id = %i', $id)
				->execute()
				->setRowClass(ArticleEntity::class)
				->fetch();
}

Generate all

To generate all entities run from database tables and views run

console entity:generate 

Generate one table/view only

console entity:generate table_name

Generate from query

Write your query in .sql file after that run command:

 console entity:generate --query-file=path/to/QueryFile.sql EntityName

Generate from directory where query sql files are

Write your queries in one folder in .sql files and (re) generate entities for all queries with:

 console entity:generate --query-dir=/path/to/dir

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固