/**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param Application $app An Application instance
  */
 public function register(Application $app)
 {
     $app['console.options'] = $app->share(function () {
         return array('name' => 'Silex Application', 'version' => Application::VERSION);
     });
     $app['console.commands'] = $app->share(function () {
         return array();
     });
     $app['console'] = $app->share(function (Application $app) {
         $options = $app['console.options'];
         $console = new \Symfony\Component\Console\Application($options['name'], $options['version']);
         $console->getHelperSet()->set(new SilexHelper($app));
         $console->addCommands($app['console.commands']);
         return $console;
     });
 }
Example #2
0
 *   147 Stepaside Park, Stepaside, Dublin 18, Ireland.
 *   Barry O'Donovan <barry _at_ opensolutions.ie>
 *
 * @copyright Copyright (c) 2011 Open Source Solutions Limited
 * @license http://opensource.org/licenses/gpl-3.0.html GNU General Public License, version 3 (GPLv3)
 * @author Open Source Solutions Limited <info _at_ opensolutions.ie>
 * @author Barry O'Donovan <barry _at_ opensolutions.ie>
 */
/**
 * Doctrine CLI script
 */
//ini_set('memory_limit', -1);
require_once dirname(__FILE__) . '/../vendor/autoload.php';
require_once dirname(__FILE__) . '/utils.inc';
if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == '--database') {
    $db = $_SERVER['argv'][2];
    array_splice($_SERVER['argv'], 1, 2);
} else {
    $db = 'default';
}
$application = get_zend_application();
$em = get_doctrine2_entity_manager($application, $db);
$helpers = array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em));
$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
$cli->setCatchExceptions(true);
$helperSet = $cli->getHelperSet();
foreach ($helpers as $name => $helper) {
    $helperSet->set($helper, $name);
}
Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli);
$cli->run();
Example #3
0
<?php

$environment = strtolower(getenv('APPLICATION_ENV'));
if (!$environment) {
    echo 'APPLICATION_ENV must be configured!' . PHP_EOL;
    exit(255);
}
$di = (include realpath(__DIR__ . '/../') . '/configs/bootstrap.php');
$di->get('config')->logger->default_name = 'console';
$di->get('error_catcher')->register();
$di->get('error_catcher')->setFatalCallback(function ($message) use($di) {
    $di->get('logger_helper')->getLogger()->emergency($message);
});
$di->get('error_catcher')->setExceptionCallback(function (\Exception $exception) use($di) {
    $di->get('logger_helper')->getLogger()->error($exception);
});
$doctrineConn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'pdo_mysql', 'pdo' => $di->get('pdo')));
$symfonyConsoleApp = new \Symfony\Component\Console\Application();
$symfonyConsoleApp->getHelperSet()->set(new \Pozitim\Console\DiHelper($di));
$symfonyConsoleApp->getHelperSet()->set(new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($doctrineConn));
$symfonyConsoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand());
$symfonyConsoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand());
$symfonyConsoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand());
$symfonyConsoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand());
$symfonyConsoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\LatestCommand());
$symfonyConsoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand());
$symfonyConsoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand());
$symfonyConsoleApp->add(new \Pozitim\CI\Console\ComposeRunnerCommand());
$symfonyConsoleApp->run();
Example #4
0
 public function executeDoctrine(array $arguments)
 {
     $_SERVER['argv'] = array_slice($arguments, 1);
     $cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', \Doctrine\Common\Version::VERSION);
     $cli->setCatchExceptions(true);
     $helperSet = $cli->getHelperSet();
     $helpers = array('em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($this->cx->getDb()->getEntityManager()));
     foreach ($helpers as $name => $helper) {
         $helperSet->set($helper, $name);
     }
     $cli->addCommands(array(new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand()));
     $cli->setAutoExit(false);
     return $cli->run();
 }
Example #5
0
<?php

/**
 * @var \MiniFrame\Di\Di $diImpl
 */
$environment = strtolower(getenv('APPLICATION_ENV'));
$diImpl = (include realpath(__DIR__ . '/../') . '/configs/bootstrap.php');
$diImpl->get('configs')->logger->name = 'console';
$diImpl->get('error_catcher')->register();
$consoleApp = new \Symfony\Component\Console\Application($diImpl->get('configs')->console_application->name);
$consoleApp->getHelperSet()->set(new \MiniFrame\ConsoleApplication\DiHelper($diImpl));
/**
 * Diğer komutları buradan ekleyebilirsiniz:
 *
 * $symfonyConsoleApp->add(new \Application\Console\MyCommand());
 */
/**
 * Doctrine ile ilgili komutlar özel olarak ekleniyor.
 */
$doctrineConn = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'pdo_mysql', 'pdo' => $diImpl->get('pdo')));
$consoleApp->getHelperSet()->set(new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($doctrineConn));
$consoleApp->getHelperSet()->set(new \Symfony\Component\Console\Helper\DialogHelper(), 'dialog');
$consoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand());
$consoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand());
$consoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand());
$consoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand());
$consoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\LatestCommand());
$consoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand());
$consoleApp->add(new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand());
$consoleApp->run();
        if (file_exists($configFile)) {
            $configFound = true;
            break;
        }
    }
    if (!$found) {
        throw new \Exception("Cannot find configuration file '{$configFile}'");
    }
    $config = (include $configFile);
    if (!$config) {
        throw new \Exception("Cannot parse or empty configuration file '{$configFile}'");
    }
} catch (\Exception $e) {
    echo $e->getMessage() . "\n";
    exit(1);
}
$setup = new OpenstoreSchema\Core\Tools\Setup($config['database'], $config['paths'], $config['namespace']);
$setup->setEnvironment($config['env']);
$setup->setProxyPath($config['proxy_path']);
$em = $setup->getEntityManager();
$cli = new Symfony\Component\Console\Application('openstore-schema-core console', '1.0.0');
$cli->setCatchExceptions(true);
// commands
$cli->addCommands(array(new Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), new Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), new Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), new Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), new Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), new Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), new Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), new Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), new Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), new Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), new Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(), new Doctrine\ORM\Tools\Console\Command\InfoCommand(), new OpenstoreSchema\Core\Tools\Console\Command\Schema\CreateCommand(), new OpenstoreSchema\Core\Tools\Console\Command\Schema\RecreateExtraCommand(), new OpenstoreSchema\Core\Tools\Console\Command\Schema\UpdateCommand(), new OpenstoreSchema\Core\Tools\Console\Command\Schema\DropCommand()));
// helpers
$helpers = array('db' => new Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em), 'question' => new Symfony\Component\Console\Helper\QuestionHelper());
foreach ($helpers as $name => $helper) {
    $cli->getHelperSet()->set($helper, $name);
}
$cli->run();
//return $cli;
Example #7
0
<?php

/**
 * Bootstrap script for console
 *
 * This file is a part of Portable ZipCode API
 *
 * @copyright 2013 Kazuyuki Hayashi
 * @license   MIT
 * @author    Kazuyuki Hayashi <*****@*****.**>
 */
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
$app = (require __DIR__ . '/bootstrap.php');
$app->boot();
$console = new \Symfony\Component\Console\Application('kzykhys/zip-finder', '1.0.0');
$console->getHelperSet()->set(new ConnectionHelper($app['db']), 'db');
$console->getHelperSet()->set(new EntityManagerHelper($app['orm.em']), 'em');
$createCommand = new CreateCommand();
$updateCommand = new UpdateCommand();
$dropCommand = new DropCommand();
$console->addCommands(array($createCommand->setName('doctrine:schema:create'), $updateCommand->setName('doctrine:schema:update'), $dropCommand->setName('doctrine:schema:drop'), new \KzykHys\ZipFinder\Command\CSV\ImportCommand($app), new \KzykHys\ZipFinder\Command\Build\PharCommand(), new \KzykHys\ZipFinder\Command\CSV\DownloadCommand(), new \KzykHys\ZipFinder\Command\Build\PackageCommand()));
$console->run();
<?php

require_once 'autoloader.php';
# Use adapter PDO_PGSQL or PDO_MYSQL :)
$dbConfig = new \Zend_Config(array('database' => array('adapter' => ADAPTER, 'params' => array('host' => HOST, 'dbname' => DATABASE, 'username' => USER, 'password' => PASS, 'port' => PORT))));
$dbAdapter = \Zend_Db::factory($dbConfig->database);
$cli = new \Symfony\Component\Console\Application('Ionix Zend Form Generator', 'Version 1');
$cli->setCatchExceptions(true);
$cli->getHelperSet()->set(new \Ionix\Console\Helper\DbAdapter($dbAdapter), 'dbAdapter');
$cli->addCommands(array(new \Ionix\Console\Command\Zend\Form\GenerateFormsCommand()));
$cli->run();