本文整理汇总了PHP中Doctrine\ORM\Tools\Console\ConsoleRunner::run方法的典型用法代码示例。如果您正苦于以下问题:PHP ConsoleRunner::run方法的具体用法?PHP ConsoleRunner::run怎么用?PHP ConsoleRunner::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Tools\Console\ConsoleRunner
的用法示例。
在下文中一共展示了ConsoleRunner::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$entityManager = null;
if (is_array($_SERVER['argv'])) {
foreach ($_SERVER['argv'] as $key => $value) {
if (substr($value, 0, 5) === '--em=') {
$entityManager = substr($value, 5);
unset($_SERVER['argv'][$key]);
if (is_int($_SERVER['argc'])) {
$_SERVER['argc']--;
}
break;
}
}
}
$commands = $this->container->getDoctrine()->getCommands();
$helperSet = $this->container->getDoctrine()->getHelperSet($entityManager);
if (!$helperSet instanceof HelperSet) {
foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof HelperSet) {
$helperSet = $helperSetCandidate;
break;
}
}
}
ConsoleRunner::run($helperSet, $commands);
}
示例2: route_model
public function route_model()
{
// GET ENTITY MANAGER
$em = $this->doctrine->getEntityManager();
// CALL CONSOLE RUNNER
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)));
// GET CONSOLE RUNNER
return \Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet);
}
示例3: actionIndex
public function actionIndex()
{
/**
* @var $em \Doctrine\ORM\EntityManager
*/
$em = ApplicationConsole::app()->db->doctrine;
$helperSet = new HelperSet(['db' => new ConnectionHelper($em->getConnection()), 'em' => new EntityManagerHelper($em)]);
//unset($_SERVER['argv'][0]);
unset($_SERVER['argv'][1]);
$_SERVER['argv'] = array_values($_SERVER['argv']);
\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet);
}
示例4: indexAction
public function indexAction()
{
if ($this->getRequest() instanceof ConsoleRequest) {
$params = $this->params()->fromRoute();
switch ($params['api']) {
case 'doctrine':
global $argv;
array_shift($argv);
// index.php
array_shift($argv);
// external
$_SERVER['argv'] = $argv;
$helperSet = ConsoleRunner::createHelperSet($this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'));
ConsoleRunner::run($helperSet, array());
break;
default:
return 'Could not find an option for external tool: ' . $params['api'];
}
return '';
}
return new ViewModel();
}
示例5: actionIndex
public function actionIndex()
{
unset($_SERVER['argv'][1]);
$option = '--' . \yii\console\Application::OPTION_APPCONFIG . '=';
foreach ($_SERVER['argv'] as $key => $param) {
if (strpos($param, $option) === 0) {
$keyToUnset = $key;
break;
}
}
if (isset($keyToUnset)) {
unset($_SERVER['argv'][$keyToUnset]);
unset($keyToUnset);
}
// Currently, symfony application uses a deprecated class (DialogHelper).
// Don't throw an exception.
$currentLevel = error_reporting();
error_reporting($currentLevel ^ E_USER_DEPRECATED);
$doctrine = $this->getDoctrineComponent();
$entityManager = $doctrine->getEntityManager();
$helperSet = ConsoleRunner::createHelperSet($entityManager);
$result = ConsoleRunner::run($helperSet);
return $result;
}
示例6: getcwd
<?php
require_once '../../Library/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', 'Doctrine');
$classLoader->register();
$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
$helperSet = null;
if (file_exists($configFile)) {
if (!is_readable($configFile)) {
trigger_error('Configuration file [' . $configFile . '] does not have read permission.', E_ERROR);
}
require $configFile;
foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof \Symfony\Component\Console\Helper\HelperSet) {
$helperSet = $helperSetCandidate;
break;
}
}
}
$helperSet = $helperSet ?: new \Symfony\Component\Console\Helper\HelperSet();
\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet);
示例7: array
@(include_once __DIR__ . '/../vendor/autoload.php') || @(include_once __DIR__ . '/../../../autoload.php');
$directories = array(getcwd(), getcwd() . DIRECTORY_SEPARATOR . 'config');
$configFile = null;
foreach ($directories as $directory) {
$configFile = $directory . DIRECTORY_SEPARATOR . 'cli-config.php';
if (file_exists($configFile)) {
break;
}
}
if (!file_exists($configFile)) {
ConsoleRunner::printCliConfigTemplate();
exit(1);
}
if (!is_readable($configFile)) {
echo 'Configuration file [' . $configFile . '] does not have read permission.' . "\n";
exit(1);
}
Type::overrideType(Type::DATETIME, Database::getUTCDateTimeTypeClass());
Type::addType('json', 'Sonata\\Doctrine\\Types\\JsonType');
$commands = array(new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\LatestCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand());
$helperSet = (require $configFile);
if (!$helperSet instanceof HelperSet) {
foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof HelperSet) {
$helperSet = $helperSetCandidate;
break;
}
}
}
\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet, $commands);
示例8: ClassLoader
<?php
//doctrine-cli.php
use Symfony\Component\Console\Helper\HelperSet, Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper, Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper, Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\ClassLoader;
require_once "vendor/autoload.php";
require_once "../Models/Entity/AbstractEntity.php";
$loader = new ClassLoader("Entity", "models");
$loader->register();
$dbParams = array('driver' => 'pdo_mysql', 'user' => 'oringo_fdd', 'password' => 'atitudinefdd', 'host' => 'localhost', 'dbname' => 'oringo_neo', 'charset' => "utf8");
$path = array('../../NeoMvc/Models/Entity');
$config = Setup::createAnnotationMetadataConfiguration($path, true);
$config->setProxyDir("../../NeoMvc/Proxy");
$config->setProxyNamespace("Proxy");
//$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
$em = EntityManager::create($dbParams, $config);
$helperSet = new HelperSet(array('em' => new EntityManagerHelper($em), 'conn' => new ConnectionHelper($em->getConnection())));
ConsoleRunner::run($helperSet);
示例9: define
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
define('PATH_ROOT', __DIR__ . '/../../../../');
require_once PATH_ROOT . 'vendor/autoload.php';
require_once __DIR__ . DIRECTORY_SEPARATOR . 'cli-config.php';
$oConsole = \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($entityManager);
\Doctrine\ORM\Tools\Console\ConsoleRunner::run($oConsole);
示例10: EntityManagerHelper
<?php
$app = (require_once __DIR__ . '/bootstrap.php');
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\DialogHelper;
use Doctrine\DBAL\Migrations\Tools\Console\Command;
use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Symfony\Component\Console\Application as SymfonyApplication;
$helpers['em'] = new EntityManagerHelper($app['orm.em']);
$helpers['dialog'] = new DialogHelper();
$helperSet = new HelperSet($helpers);
$commands = array(new Command\DiffCommand(), new Command\ExecuteCommand(), new Command\GenerateCommand(), new Command\MigrateCommand(), new Command\StatusCommand(), new Command\VersionCommand());
$application = new SymfonyApplication();
$config = new Configuration($app['db']);
$config->setName('Skel Migration');
$config->setMigrationsDirectory(__DIR__ . '/data/DoctrineMigrations');
$config->setMigrationsNamespace('Application\\Migrations');
$config->setMigrationsTableName('migration_version');
foreach ($commands as $command) {
if ($command instanceof Command\AbstractCommand) {
$command->setMigrationConfiguration($config);
}
$application->add($command);
}
ConsoleRunner::run($helperSet, $application->all());
示例11: getcwd
break;
}
}
$directories = [getcwd(), getcwd() . DIRECTORY_SEPARATOR . 'config'];
$configFile = null;
foreach ($directories as $directory) {
$configFile = $directory . DIRECTORY_SEPARATOR . 'cli-config.php';
if (file_exists($configFile)) {
break;
}
}
if (!file_exists($configFile)) {
ConsoleRunner::printCliConfigTemplate();
exit(1);
}
if (!is_readable($configFile)) {
echo 'Configuration file [' . $configFile . '] does not have read permission.' . "\n";
exit(1);
}
$commands = [];
$helperSet = (require $configFile);
if (!$helperSet instanceof HelperSet) {
foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof HelperSet) {
$helperSet = $helperSetCandidate;
break;
}
}
}
ConsoleRunner::run($helperSet, $commands);
示例12: run
/**
* Run doctrine console tool.
*/
public function run()
{
$helperSet = $this->getConsoleHelperSet();
ConsoleRunner::run($helperSet, $this->getConsoleCommands($helperSet));
}
示例13: spl_autoload_register
<?php
require_once __DIR__ . '/vendor/autoload.php';
$isDevMode = true;
$config = \Doctrine\ORM\Tools\Setup::createXMLMetadataConfiguration(array(__DIR__ . '/xml'), $isDevMode);
$params = (include __DIR__ . '/db-params.php');
$em = \Doctrine\ORM\EntityManager::create($params, $config);
$db = $em->getConnection();
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em), 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($db), 'dialog' => new \Symfony\Component\Console\Helper\DialogHelper()));
spl_autoload_register(function ($name) {
$fn = __DIR__ . "/entities/{$name}.php";
if (is_readable($fn)) {
require_once $fn;
}
});
\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet, array(new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand()));
示例14: array
#!/usr/bin/env php
<?php
use Doctrine\ORM\Tools\Console\ConsoleRunner;
require_once __DIR__ . '/../vendor/autoload.php';
$dbConfig = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration([__DIR__ . '/../src'], true, null, null, false);
$conn = array('driver' => 'pdo_sqlite', 'path' => __DIR__ . '/../data/db.sqlite');
$entityManager = \Doctrine\ORM\EntityManager::create($conn, $dbConfig);
$helper = ConsoleRunner::createHelperSet($entityManager);
ConsoleRunner::run($helper);
示例15: Doctrine_ORM
$doctrine_orm = new Doctrine_ORM($database_group);
// add console helpers
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array('db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($doctrine_orm->getEntityManager()->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($doctrine_orm->getEntityManager())));
// create and run Symfony Console application
$cli = new Symfony\Component\Console\Application('Kohana Doctrine Command Line Interface</info>' . PHP_EOL . '<comment>use --database-group to specifify another group from database.php (defaut: default)</comment>' . PHP_EOL . '<info>Doctrine', \Doctrine\ORM\Version::VERSION);
$cli->setCatchExceptions(true);
// Register All Doctrine Commands
\Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli);
// Adding own helpers
foreach (Kohana::$config->load('doctrine')->get('console_helpers', array()) as $alias => $helper) {
$helperSet->set($helper);
}
// Set helperSet
$cli->setHelperSet($helperSet);
// Run with helperset and add own commands
\Doctrine\ORM\Tools\Console\ConsoleRunner::run($helperSet, Kohana::$config->load('doctrine')->get('console_commands', array()));
/**
* init from configured paths
* @param type $system
* @param type $application
* @param type $modules
*/
function initLikeIndex($system, $application, $modules)
{
if (!$system || !$application || !$modules) {
// your installation paths (needed to run CLI)
if (file_exists(__DIR__ . '/../../../../application/')) {
$system = realpath(__DIR__ . '/../../../kohana/system/');
$application = realpath(__DIR__ . '/../../../../application/');
} else {
$system = realpath(__DIR__ . '/../../../system/');