0
我是新的Silex框架。但我對Symfony框架有所瞭解。我想像在Symfony框架中一樣在Silex中生成實體。爲symfony1.2我們運行這個:在Silex框架中生成實體
php app/console doctrine:generate:entities MusicBox
但我怎麼可以創建Silex的實體?我已經安裝一切事物都像學說等
我是新的Silex框架。但我對Symfony框架有所瞭解。我想像在Symfony框架中一樣在Silex中生成實體。爲symfony1.2我們運行這個:在Silex框架中生成實體
php app/console doctrine:generate:entities MusicBox
但我怎麼可以創建Silex的實體?我已經安裝一切事物都像學說等
首先添加學說ORM提供商
https://github.com/dflydev/dflydev-doctrine-orm-service-provider
然後創建教義命令console.php的。
這是我的Doctrine控制檯文件,需要更改它。
require_once(__DIR__ . '/../vendor/autoload.php');
$app = new App\Application();
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
$console = new Application();
$app->boot();
$helperSet = new \Symfony\Component\Console\Helper\HelperSet([
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($app['db']),
'dialog' => new \Symfony\Component\Console\Helper\QuestionHelper(),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($app['db.orm.em'])
]);
$console->setHelperSet($helperSet);
$console->addCommands([
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(),
// DBAL Commands
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// ORM Commands
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(),
]);
$console->run();
閱讀文檔http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html – malcolm
有硅石中產生的實體沒有控制檯命令。正如@malcolm所指出的那樣,您應該直接使用doctrine命令(或者如果您確實需要整個ORM,請使用Symfony) – mTorres