PHP code example of thecodingmachine / tdbm-fluid-schema-builder

1. Go to this page and download the library: Download thecodingmachine/tdbm-fluid-schema-builder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thecodingmachine / tdbm-fluid-schema-builder example snippets


$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()->