Last active
September 28, 2015 23:08
-
-
Save chanmix51/1510801 to your computer and use it in GitHub Desktop.
generate model files in Silex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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