Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
generate model files in Silex
<?php
function help()
{
printf("Usage:\n");
printf("generate_model schema environment\n");
printf("\nschema is the database schema you want to scan.\n");
printf("environment set the database connection that will be used (default: dev).\n");
exit(1);
}
if (PHP_SAPI !== 'cli') {
throw new \Exception("This is a CLI tool that therefor needs to be launched in a terminal.");
}
if (count($argv) < 2 or ! preg_match("/^[a-z0-9_]+$/", $argv[1])) {
help();
}
$env = count($argv) >= 3 ? $argv[2] : 'dev';
define('ENV', $env);
$app = require __DIR__."/../src/bootstrap.php";
$scan = new Pomm\Tools\ScanSchemaTool(array(
'schema' => $argv[1],
'database' => $app['pomm']->getDatabase(),
'prefix_dir' => __DIR__."/../src",
));
$scan->execute();
$scan->getOutputStack()->setLevel(254);
foreach ( $scan->getOutputStack() as $line )
{
printf("%s\n", $line);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment