首页 文章

在Silex框架中生成Entites

提问于
浏览
0

我是Silex框架的新手 . 但我对Symfony框架有所了解 . 我想像在Symfony框架中一样在Silex中生成一个实体 . 对于Symfony,我们运行:

php app/console doctrine:generate:entities MusicBox

但是如何在Silex中创建实体?我已经设置了所有的东西,如教义等 .

1 回答

  • 1

    首先添加Doctrine ORM提供程序

    https://github.com/dflydev/dflydev-doctrine-orm-service-provider

    然后使用doctrine命令创建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();
    

相关问题