2 Star 1 Fork 0

Eward.Chen/codeigniter3-doctrine2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cli.php 2.36 KB
一键复制 编辑 原始数据 按行查看 历史
Eward.Chen 提交于 2015-06-20 13:43 . update
<?php
define('DS', DIRECTORY_SEPARATOR);
define('BASEPATH', __DIR__ .DS);
define('APPLICATION', BASEPATH. 'application'.DS);
$loader = require_once APPLICATION ."vendor/autoload.php";
require_once APPLICATION.'config'.DS.'database.php' ;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
$paths = [
BASEPATH . 'application' . DS . 'models'
];
$isDevMode = true;
// the connection configuration
$connectionOptions = array(
'driver' => 'pdo_mysql',
'user' => $db['default']['username'],
'password' => $db['default']['password'],
'host' => $db['default']['hostname'],
'dbname' => $db['default']['database']
);
$proxies = BASEPATH . 'application' . DS . 'models'.DS.'proxies';
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, $proxies);
$entityManager = EntityManager::create($connectionOptions, $config);
//cli.php
$helperSet = ConsoleRunner::createHelperSet($entityManager);
$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface (CodeIgniter integration by Caokai)', Doctrine\ORM\Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->addCommands(array(
// DBAL 命令
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// ORM 命令
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->run();
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/eward.chen/codeigniter3-doctrine2.git
git@gitee.com:eward.chen/codeigniter3-doctrine2.git
eward.chen
codeigniter3-doctrine2
codeigniter3-doctrine2
master

搜索帮助