Skip to content

ManifestWebDesign/dabl-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

dabl-generator

Simple MVC code generator

Example

Setup

use Dabl\Generator\DefaultGenerator;
use Dabl\Query\DBManager;

// setup database connection
DBManager::addConnection('test', array(
    'driver' => 'sqlite',
    'dbname' => ':memory:'
));

// create databse tables
$conn = DBManager::getConnection('test');
$conn->exec('CREATE TABLE user (
    id INTEGER,
    name,
    PRIMARY KEY(id ASC)
)');

$conn->exec('CREATE TABLE post (
    id INTEGER,
    user_id INTEGER,
    content,
    PRIMARY KEY(id ASC),
    FOREIGN KEY(user_id) REFERENCES user(id)
)');

Generate

$generator = new DefaultGenerator('test');
$generator->generateModels(
    ['user', 'post'],
    './models'
);

$generator->generateViews(
    ['user', 'post'],
    './views'
);

$generator->generateControllers(
    ['user', 'post'],
    './controllers'
);

About

DABL ORM code generator

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages