即使安装了 doctrine/doctrine-bundle,Doctrine 命令也不会出现在 Symfony 3.4 控制台中
Doctrine commands not showing up in Symfony 3.4 console even though doctrine/doctrine-bundle is installed
我有一个旧的 Symfony 3.4 应用程序 (https://github.com/opencfp/opencfp),需要添加 Doctrine 以便我可以用 Symfony Guard 替换现有的 auth/acl 解决方案,然后开始升级到 Symfony 5. 我已经安装了 doctrine/doctrine-bundle 并且可以看到命令在 vendor 目录中,但是当我 运行 bin/console none 的 doctrine 命令出现时。
这是我在供应商目录中搜索 Doctrine 控制台命令时发现的内容。
doctrine/doctrine-bundle/Resources/config/dbal.xml
87: <tag name="console.command" command="doctrine:database:create" />
93: <tag name="console.command" command="doctrine:database:drop" />
97: <tag name="console.command" command="doctrine:database:import" />
doctrine/doctrine-bundle/Command/Proxy/ImportDoctrineCommand.php
23: ->setName('doctrine:database:import')
doctrine/doctrine-bundle/Command/DropDatabaseDoctrineCommand.php
29: ->setName('doctrine:database:drop')
doctrine/doctrine-bundle/Command/CreateDatabaseDoctrineCommand.php
25: ->setName('doctrine:database:create')
当我 运行 bin/console 我没有看到 doctrine 命名空间中的任何命令
Symfony 3.4.35 (kernel: OpenCFP, env: development, debug: true)
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The Environment name. [default: "development"]
--no-debug Switches off debug mode.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
about Displays information about the current project
help Displays help for a command
list Lists commands
assets
assets:install Installs bundles web assets under a public directory
cache
cache:clear Clears the cache
cache:pool:clear Clears cache pools
cache:pool:prune Prunes cache pools
cache:warmup Warms up an empty cache
config
config:dump-reference Dumps the default configuration for an extension
debug
debug:autowiring Lists classes/interfaces you can use for autowiring
debug:config Dumps the current configuration for an extension
debug:container Displays current services for an application
debug:event-dispatcher Displays configured listeners for an application
debug:form Displays form type information
debug:router Displays current routes for an application
debug:swiftmailer Displays current mailers for an application
debug:translation Displays translation messages information
debug:twig Shows a list of twig functions, filters, globals and tests
eloquent
eloquent:make:seeder Create a new seeder class
eloquent:migrate Executes a migration.
eloquent:migrate:fresh Drop all tables and re-run all migrations.
eloquent:migrate:install Creates the migration repository.
eloquent:migrate:make Creates a new migration file
eloquent:migrate:refresh Reset and re-run all migrations
eloquent:migrate:reset Rollback all database migrations
eloquent:migrate:rollback Rollback the last database migration
eloquent:migrate:status Show the status of each migration
eloquent:seed Seed the database with records
lint
lint:twig Lints a template and outputs encountered errors
lint:xliff Lints a XLIFF file and outputs encountered errors
lint:yaml Lints a file and outputs encountered errors
router
router:match Helps debug routes by simulating a path info match
server
server:log Starts a log server that displays logs in real time
server:run Runs a local web server
server:start Starts a local web server in the background
server:status Outputs the status of the local web server
server:stop Stops the local web server that was started with the server:start command
swiftmailer
swiftmailer:email:send Send simple email message
swiftmailer:spool:send Sends emails from the spool
translation
translation:update Updates the translation file
user
user:create Creates a new user
user:demote Demote an existing user from a role
user:promote Promote an existing user to a role
我也有一些自定义命令。
非常感谢任何帮助。
根据我从 vendor/doctrine/doctrine-bundle/DependencyInjection/DoctrineExtension.php
收集到的信息,需要正确配置 DBAL 和 ORM 才能启用命令:
public function load(array $configs, ContainerBuilder $container)
{
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$this->adapter->loadServicesConfiguration($container);
if (! empty($config['dbal'])) {
$this->dbalLoad($config['dbal'], $container);
$this->loadMessengerServices($container);
}
if (empty($config['orm'])) {
return;
}
if (empty($config['dbal'])) {
throw new LogicException('Configuring the ORM layer requires to configure the DBAL layer as well.');
}
$this->ormLoad($config['orm'], $container);
}
ormLoad
和dbalLoad
负责注册命令。
在此特定实例中,需要注册 Doctrine:
doctrine:
dbal:
url: mysql://db_user:db_password@127.0.0.1:3306/db_name
orm: ~
以上位于 resources/config/config.yml
或该文件夹的任何其他文件的末尾。另外,您需要进行适当的调整。
doctrine
doctrine:cache:clear-collection-region Clear a second-level cache collection region
doctrine:cache:clear-entity-region Clear a second-level cache entity region
doctrine:cache:clear-metadata Clears all metadata cache for an entity manager
doctrine:cache:clear-query Clears all query cache for an entity manager
doctrine:cache:clear-query-region Clear a second-level cache query region
doctrine:cache:clear-result Clears result cache for an entity manager
doctrine:cache:contains Check if a cache entry exists
doctrine:cache:delete Delete a cache entry
doctrine:cache:flush [doctrine:cache:clear] Flush a given cache
doctrine:cache:stats Get stats on a given cache provider
doctrine:database:create Creates the configured database
doctrine:database:drop Drops the configured database
doctrine:database:import Import SQL file(s) directly to Database.
doctrine:ensure-production-settings Verify that Doctrine is properly configured for a production environment
doctrine:generate:entities [generate:doctrine:entities] Generates entity classes and method stubs from your mapping information
doctrine:mapping:convert [orm:convert:mapping] Convert mapping information between supported formats
doctrine:mapping:import Imports mapping information from an existing database
doctrine:mapping:info
doctrine:query:dql Executes arbitrary DQL directly from the command line
doctrine:query:sql Executes arbitrary SQL directly from the command line.
doctrine:schema:create Executes (or dumps) the SQL needed to generate the database schema
doctrine:schema:drop Executes (or dumps) the SQL needed to drop the current database schema
doctrine:schema:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata
doctrine:schema:validate Validate the mapping files
我有一个旧的 Symfony 3.4 应用程序 (https://github.com/opencfp/opencfp),需要添加 Doctrine 以便我可以用 Symfony Guard 替换现有的 auth/acl 解决方案,然后开始升级到 Symfony 5. 我已经安装了 doctrine/doctrine-bundle 并且可以看到命令在 vendor 目录中,但是当我 运行 bin/console none 的 doctrine 命令出现时。
这是我在供应商目录中搜索 Doctrine 控制台命令时发现的内容。
doctrine/doctrine-bundle/Resources/config/dbal.xml
87: <tag name="console.command" command="doctrine:database:create" />
93: <tag name="console.command" command="doctrine:database:drop" />
97: <tag name="console.command" command="doctrine:database:import" />
doctrine/doctrine-bundle/Command/Proxy/ImportDoctrineCommand.php
23: ->setName('doctrine:database:import')
doctrine/doctrine-bundle/Command/DropDatabaseDoctrineCommand.php
29: ->setName('doctrine:database:drop')
doctrine/doctrine-bundle/Command/CreateDatabaseDoctrineCommand.php
25: ->setName('doctrine:database:create')
当我 运行 bin/console 我没有看到 doctrine 命名空间中的任何命令
Symfony 3.4.35 (kernel: OpenCFP, env: development, debug: true)
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
-e, --env=ENV The Environment name. [default: "development"]
--no-debug Switches off debug mode.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
about Displays information about the current project
help Displays help for a command
list Lists commands
assets
assets:install Installs bundles web assets under a public directory
cache
cache:clear Clears the cache
cache:pool:clear Clears cache pools
cache:pool:prune Prunes cache pools
cache:warmup Warms up an empty cache
config
config:dump-reference Dumps the default configuration for an extension
debug
debug:autowiring Lists classes/interfaces you can use for autowiring
debug:config Dumps the current configuration for an extension
debug:container Displays current services for an application
debug:event-dispatcher Displays configured listeners for an application
debug:form Displays form type information
debug:router Displays current routes for an application
debug:swiftmailer Displays current mailers for an application
debug:translation Displays translation messages information
debug:twig Shows a list of twig functions, filters, globals and tests
eloquent
eloquent:make:seeder Create a new seeder class
eloquent:migrate Executes a migration.
eloquent:migrate:fresh Drop all tables and re-run all migrations.
eloquent:migrate:install Creates the migration repository.
eloquent:migrate:make Creates a new migration file
eloquent:migrate:refresh Reset and re-run all migrations
eloquent:migrate:reset Rollback all database migrations
eloquent:migrate:rollback Rollback the last database migration
eloquent:migrate:status Show the status of each migration
eloquent:seed Seed the database with records
lint
lint:twig Lints a template and outputs encountered errors
lint:xliff Lints a XLIFF file and outputs encountered errors
lint:yaml Lints a file and outputs encountered errors
router
router:match Helps debug routes by simulating a path info match
server
server:log Starts a log server that displays logs in real time
server:run Runs a local web server
server:start Starts a local web server in the background
server:status Outputs the status of the local web server
server:stop Stops the local web server that was started with the server:start command
swiftmailer
swiftmailer:email:send Send simple email message
swiftmailer:spool:send Sends emails from the spool
translation
translation:update Updates the translation file
user
user:create Creates a new user
user:demote Demote an existing user from a role
user:promote Promote an existing user to a role
我也有一些自定义命令。
非常感谢任何帮助。
根据我从 vendor/doctrine/doctrine-bundle/DependencyInjection/DoctrineExtension.php
收集到的信息,需要正确配置 DBAL 和 ORM 才能启用命令:
public function load(array $configs, ContainerBuilder $container)
{
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
$this->adapter->loadServicesConfiguration($container);
if (! empty($config['dbal'])) {
$this->dbalLoad($config['dbal'], $container);
$this->loadMessengerServices($container);
}
if (empty($config['orm'])) {
return;
}
if (empty($config['dbal'])) {
throw new LogicException('Configuring the ORM layer requires to configure the DBAL layer as well.');
}
$this->ormLoad($config['orm'], $container);
}
ormLoad
和dbalLoad
负责注册命令。
在此特定实例中,需要注册 Doctrine:
doctrine:
dbal:
url: mysql://db_user:db_password@127.0.0.1:3306/db_name
orm: ~
以上位于 resources/config/config.yml
或该文件夹的任何其他文件的末尾。另外,您需要进行适当的调整。
doctrine
doctrine:cache:clear-collection-region Clear a second-level cache collection region
doctrine:cache:clear-entity-region Clear a second-level cache entity region
doctrine:cache:clear-metadata Clears all metadata cache for an entity manager
doctrine:cache:clear-query Clears all query cache for an entity manager
doctrine:cache:clear-query-region Clear a second-level cache query region
doctrine:cache:clear-result Clears result cache for an entity manager
doctrine:cache:contains Check if a cache entry exists
doctrine:cache:delete Delete a cache entry
doctrine:cache:flush [doctrine:cache:clear] Flush a given cache
doctrine:cache:stats Get stats on a given cache provider
doctrine:database:create Creates the configured database
doctrine:database:drop Drops the configured database
doctrine:database:import Import SQL file(s) directly to Database.
doctrine:ensure-production-settings Verify that Doctrine is properly configured for a production environment
doctrine:generate:entities [generate:doctrine:entities] Generates entity classes and method stubs from your mapping information
doctrine:mapping:convert [orm:convert:mapping] Convert mapping information between supported formats
doctrine:mapping:import Imports mapping information from an existing database
doctrine:mapping:info
doctrine:query:dql Executes arbitrary DQL directly from the command line
doctrine:query:sql Executes arbitrary SQL directly from the command line.
doctrine:schema:create Executes (or dumps) the SQL needed to generate the database schema
doctrine:schema:drop Executes (or dumps) the SQL needed to drop the current database schema
doctrine:schema:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata
doctrine:schema:validate Validate the mapping files