定制 thecodingmachine/tdbm-fluid-schema-builder 二次开发

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

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

thecodingmachine/tdbm-fluid-schema-builder

最新稳定版本:v2.0.0

Composer 安装命令:

composer require thecodingmachine/tdbm-fluid-schema-builder

包简介

Build and modify your database schema used by TDBM using a fluid syntax.

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License Scrutinizer Code Quality Build Status Coverage Status

Fluid schema builder for TDBM

Build and modify your database schema using DBAL and a fluid syntax. This project allows you to tailor your database schema to TDBM (it will allow you to easily add annotations that TDBM can read).

It is a super-set of dbal-fluid-schema-builder.

If you don't know dbal-fluid-schema-builder, check the documentation first.

Why?

TDBM can read a number of annotations in the schema comments (see TDBM annotations documentation).

This library allows to write these annotations using functions added to the "dbal-fluid-schema-builder".

What's added?

$db = new TdbmFluidSchema($schema);

// Customize the name of the Bean class
$posts = $db->table('posts')->customBeanName('Article');

// You can pass a new 'v1' or 'v4' parameter to uuid().
// This will generate a @UUID TDBM annotation that will help TDBM autogenerate the UUID 
$posts = $db->table('posts')->uuid('v4');

// Customize the visibility of a column
$db->table('posts')
   ->column('user_id')->references('users')
                      ->protectedGetter() // The Post.getUser() method is protected
                      ->protectedSetter() // The Post.setUser() method is protected
                      ->protectedOneToMany() // The User.getPosts() method is protected

// Customize implemented interfaces
$db->table('posts')
   ->implementsInterface('App\\PostInterface')  // The generated bean will implement interface App\\PostInterface
   ->implementsInterfaceOnDao('App\\PostDaoInterface'); // The generated DAO will implement interface App\\PostDaoInterface

// The "posts" table will generate a GraphQL type (i.e. the bean will be annotated with the GraphQLite @Type annotation).
$posts = $db->table('posts')->graphqlType();

// You can pass a new 'v1' or 'v4' parameter to uuid().
// This will generate a @UUID TDBM annotation that will help TDBM autogenerate the UUID 
$posts = $db->table('posts')->column('title')->string(50)->graphqlField() // The column is a GraphQL field
            ->fieldName('the_title') // Let's set the name of the field to a different value 
            ->logged() // The user must be logged to view the field
            ->right('CAN_EDIT') // The user must have the 'CAN_EDIT' right to view the field
            ->failWith(null) // If the user is not logged or has no right, let's serve 'null'
            ->endGraphql();

// You can pass instructions on how JSON serialization occurs.
// This will generate a set of JSONxxx annotations.
$nodes = $db->table('nodes')
    ->column('id')->integer()->primaryKey()->autoIncrement()->jsonSerialize()->ignore()
    ->column('alias_id')->references('nodes')->null()->jsonSerialize()->recursive()
    ->column('parent_id')->references('nodes')->null()->jsonSerialize()->include()
    ->column('root_id')->references('nodes')->null()->jsonSerialize()->ignore()
    ->column('owner_id')->references('authors')->null()->jsonSerialize()->formatUsingProperty('name')->include()
    ->column('owner_country')->references('authors')->null()->jsonSerialize()->formatUsingMethod('getCountryName')->include()
    ->column('name')->string()->jsonSerialize()->key('basename')
    ->column('size')->integer()->notNull()->default(0)->jsonSerialize()->numericFormat(null, null, null, ' o')
    ->column('weight')->float()->null()->jsonSerialize()->numericFormat(2, ',', '.', 'g')
    ->column('created_at')->date()->null()->jsonSerialize()->datetimeFormat("Y-m-d")
    ->column('another_parent')->references('nodes')->comment('@JsonCollection("entries") @JsonFormat(property="entry")');

$db->junctionTable('posts', 'users')->graphqlField(); // Expose the many-to-many relationship as a GraphQL field.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-11