This software is EXPERIMENTAL and not ready for production. It is just a proof of concept.
The application is intended to create:
- Doctrine1
- Doctrine2
- Zend DbTable
- Zend Rest Controller
- JS Sencha3Model
- Propel (not implemented)
- CakePHP (not implemented)
schema files from MySQL Workbench models (*.mwb). It is inspired by http://code.google.com/p/mysql-workbench-doctrine-plugin/.
Support for behaviours is implemented for Doctrine1. Use the comment fields in tables.
{d:actAs}
actAs:
timestampable:
[..]
{/d:actAs}
To replace relations name by the name of the foreign key, start the foreign key name with "d:".
There is a new CLI to simplify the export process named export.php
, you can look under the cli
folder.
The CLI has feature to customize export configuration before exporting.
The syntax of CLI:
php cli/export.php [options] FILE [DEST]
Where:
options
:--export=type
, choose the result of the export, currently available types:doctrine1
, Doctrine 1.0 YAML schemadoctrine2-yml
, Doctrine 2.0 YAML schemadoctrine2-annotation
, Doctrine 2.0 Annotation classes (default)zend-dbtable
, Zend DbTablezend-restcontroller
, Zend Rest Controllerjs-sencha3model
, JS Sencha3Model
--config=file
, read export parameters from file (in JSON format)--saveconfig
, save export parameters to fileexport.json
, later can be used as value for--config=file
--zip
, compress the result--help
, show the usage (or suppress any parameters)
FILE
, the mwb file to exportDEST
, the destination directory (optional), if not specified current directory assumed
Sample usage:
php cli/export.php --export=doctrine1 example/data/test.mwb ./generated
php cli/export.php --zip example/data/test.mwb
Sample export paramaters (JSON) for doctrine2-annotation:
{
"export": "doctrine2-annotation",
"zip": false,
"dir": "temp",
"params": {
"backupExistingFile": true,
"skipPluralNameChecking": false,
"enhancedManyToManyDetection": false,
"bundleNamespace": "",
"entityNamespace": "",
"repositoryNamespace": "",
"useAnnotationPrefix": "ORM\\",
"useAutomaticRepository": true,
"indentation": 4,
"filename": "%entity%.%extension%"
}
}
General options applied to all formatter.
skipPluralNameChecking
, skip checking the plural name of model and leave as is, useful for non English table names.backupExistingFile
, if target already exists create a backup before replacing the content.
extendTableNameWithSchemaName
{d:externalRelations}
useAnnotationPrefix
indentation
useAutomaticRepository
extendTableNameWithSchemaName
bundleNamespace
entityNamespace
repositoryNamespace
tablePrefix
parentTable
indentation
Works with PHP 5.3 and up.
- Doctrine Project
- MySQL Workbench
- Symfony Project
- MySQL Workbench Doctrine Plugin - google code project
<?php
// enable autoloading of classes
require_once('lib/MwbExporter/Core/SplClassLoader.php');
$classLoader = new SplClassLoader();
$classLoader->setIncludePath('lib');
$classLoader->register();
// define a formatter
$formatter = new \MwbExporter\Formatter\Doctrine2\Annotation\Loader();
// parse the mwb file
$mwb = new \MwbExporter\Core\Workbench\Document('myDatabaseModel.mwb', $formatter);
// show the output
echo $mwb->display();
// save as zip file in current directory and use .php as file endings
echo $mwb->zipExport(__DIR__, 'php');
?>