Exemple #1
0
include_once ROOT_PATH . "/core/spyc.php";
include_once ROOT_PATH . "/config/config.php";
//Includes all sql helpers
$sql_helper_folder = ROOT_PATH . Makiavelo::SQL_HELPERS_FOLDER;
$d = dir($sql_helper_folder);
while (false !== ($entry = $d->read())) {
    if ($entry[0] != ".") {
        include $sql_helper_folder . "/" . $entry;
    }
}
//DB connection... simple for now...
$__db_conn = DBLayer::connect();
$parameters = $argv;
if (count($parameters) > 1) {
    $mk = new Makiavelo();
    $action = $mk->getAction($parameters[1]);
    unset($parameters[0]);
    unset($parameters[1]);
    $action->execute(array_values($parameters));
} else {
    echo "Welcome to Makiavelo command line utility";
    echo "\nUsage: makiavelo [COMMAND] [ATTRIBUTES] \n";
    echo "\nValid commands:";
    echo "\n  g: Generator command";
    echo "\n     Attributes:";
    echo "\n     crud: Generates a controller, an entity and a set of views for the CRUD operations. Needs a name for the entity";
    echo "\n     controller: Generates an empty controller. Needs a controller name as parameter";
    echo "\n     migration: Generates an empty migration class.";
    echo "\n  db:create: Creates the database.";
    echo "\n  db:load: Loads all sql files related to the entities";
    echo "\n  db:migrate: Runs all pending migrations";