Skip to content

Instantly share code, notes, and snippets.

@chanmix51
Last active September 28, 2015 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chanmix51/1510801 to your computer and use it in GitHub Desktop.
Save chanmix51/1510801 to your computer and use it in GitHub Desktop.
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