6.2Symfony Console常用命令一览表

句法

php bin/console 命令 [选项] [参数]

选项

//查看帮助
-h, --help
//不输出任何消息
-q, --quiet
//查看symfony console版本
-V, --version
//开启ANSI输出
--ansi
//关闭ANSI输出
--no-ansi
//关闭交互功能
-n, --no-interaction
//切换环境,默认dev环境
-e, --env=ENV
//关闭调试模式
--no-debug
//Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
-v|vv|vvv, --verbose  

可使用命令

//查看当前项目信息
about
//查看命令帮助
help
//查看命令列表
list                                       List commands

assets

//在public目录下安装bundle里面的web assets
assets:install

cache

cache:clear                                Clear the cache
cache:pool:clear                           Clear cache pools
cache:pool:delete                          Delete an item from a cache pool
cache:pool:list                            List available cache pools
cache:pool:prune                           Prune cache pools
cache:warmup                               Warm up an empty cache

config

config:dump-reference                      Dump the default configuration for an extension

dbal

dbal:run-sql                               Executes arbitrary SQL directly from the command line.

debug

//显示可用于autowiring的classes/interfaces
debug:autowiring
//Dump the current configuration for an extension
debug:config
//Display current services for an application                              
debug:container
//Display configured listeners for an application                            
debug:event-dispatcher
//Display information about your security firewall(s)                    
debug:firewall
//显示表单类型信息                             
debug:form
//显示一个应用的当前路由信息
debug:router
//Display translation messages information
debug:translation
//显示twig functions, filters, globals and tests信息                         
debug:twig
//显示可用于classes的validation constraints                                  
debug:validator                            

doctrine

//Clear a second-level cache collection region
doctrine:cache:clear-collection-region
//Clear a second-level cache entity region     
doctrine:cache:clear-entity-region
//Clears all metadata cache for an entity manager        
doctrine:cache:clear-metadata
//Clears all query cache for an entity manager              
doctrine:cache:clear-query
//Clear a second-level cache query region                 
doctrine:cache:clear-query-region
//Clears result cache for an entity manager          
doctrine:cache:clear-result
//创建已配置的数据库                
doctrine:database:create
//删除已配置的数据库
doctrine:database:drop
//直接导入SQL文件至数据库                   
doctrine:database:import
//检查Doctrine配置是否适用生产环境
doctrine:ensure-production-settings
//在支持的格式中转换映射信息   
doctrine:mapping:convert
//从一个已经存在的数据库中导入映射信息            
doctrine:mapping:import
//显示映射信息                   
doctrine:mapping:info
//输出当前迁移文件版本
doctrine:migrations:current
//通过比较迁移文件与数据库,生成最新的迁移文件(同make:migration)         
doctrine:migrations:diff
//[dump-schema] Dump the schema for your database to a migration.                   
doctrine:migrations:dump-schema
//[execute] Execute one or more migration versions up or down manually.            
doctrine:migrations:execute
//生成一个空迁移类            
doctrine:migrations:generate
//输出迁移的最新版本               
doctrine:migrations:latest
//显示所有可用的迁移文件以及状态                 
doctrine:migrations:list
//执行迁移文件到数据库                   
doctrine:migrations:migrate
//[rollup] Rollup migrations by deleting all tracked versions and insert the one version that exists.                
doctrine:migrations:rollup
//[status] View the status of a set of migrations.                 
doctrine:migrations:status
//[sync-metadata-storage] Ensures that the metadata storage is at the latest version.                 
doctrine:migrations:sync-metadata-storage
//[up-to-date] Tells you if your schema is up-to-date.  
doctrine:migrations:up-to-date
//[version] Manually add and delete migration versions from the version table.             
doctrine:migrations:version
//执行原生dql语句                
doctrine:query:dql
//执行原生sql语句                         
doctrine:query:sql
//Executes (or dumps) the SQL needed to generate the database schema                         
doctrine:schema:create
//Executes (or dumps) the SQL needed to drop the current database schema                     
doctrine:schema:drop
//Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata                       
doctrine:schema:update
//Validate the mapping files                     
doctrine:schema:validate                   

doctrine mapping type

Main types
  * string
  * text
  * boolean
  * integer (or smallint, bigint)
  * float

Relationships / Associations
  * relation (a wizard 🧙 will help you build the relation)
  * ManyToOne
  * OneToMany
  * ManyToMany
  * OneToOne

Array/Object Types
  * array (or simple_array)
  * json
  * object
  * binary
  * blob

Date/Time Types
  * datetime (or datetime_immutable)
  * datetimetz (or datetimetz_immutable)
  * date (or date_immutable)
  * time (or time_immutable)
  * dateinterval

Other Types
  * ascii_string
  * decimal
  * guid
  * json_array

lint

//Ensure that arguments injected into services match type declarations
lint:container
//Lint a template and outputs encountered errors                            
lint:twig
//Lint an XLIFF file and outputs encountered errors                                  
lint:xliff
//Lint a file and outputs encountered errors                                 
lint:yaml                                  

make

//Creates a Guard authenticator of different flavors
make:auth
//Creates a new console command class                                  
make:command
//创建一个控制器类                              
make:controller
//为实体创建crud(包括路由,控制器以及方法,表单)                       
make:crud
//Adds a database container to your docker-compose.yaml file                                 
make:docker:database
//创建或更新实体类                    
make:entity
//Creates a new class to load Doctrine fixtures                               
make:fixtures
//创建表单                            
make:form
//Creates a new message and handler                                  
make:message
//Creates a new messenger middleware                               
make:messenger-middleware
//基于数据库的改动创建一个新的迁移文件              
make:migration
//Creates a new registration form system                            
make:registration-form
//Create controller, entity, and repositories for use with symfonycasts/reset-password-bundle                     
make:reset-password
//Creates a new serializer encoder class                   
make:serializer:encoder
//Creates a new serializer normalizer class               
make:serializer:normalizer
//Creates a new event subscriber class               
make:subscriber
//[make:unit-test|make:functional-test] Creates a new test class                            
make:test
//Creates a new Twig extension class                                 
make:twig-extension
//Creates a new security user class                      
make:use
//Creates a new validator and constraint class                               
make:validator
//Creates a new security voter class                           
make:voter                                 

router

router:match                               Help debug routes by simulating a path info match

secrets

secrets:decrypt-to-local                   Decrypt all secrets and stores them in the local vault.
secrets:encrypt-from-local                 Encrypt all local secrets to the vault.
secrets:generate-keys                      Generate new encryption keys.
secrets:list                               List all secrets.
secrets:remove                             Remove a secret from the vault.
secrets:set                                Set a secret in the vault.

security

security:encode-password                   Encode a password
security:hash-password                     Hash a user password

server

//Start a dump server that collects and displays dumps in a single place
server:dump
//Start a log server that displays logs in real time                                
server:log                                 

translation

translation:pull                           Pull translations from a given provider.
translation:push                           Push translations to a given provider.
translation:update                         Update the translation file

原创文章,作者:huoxiaoqiang,如若转载,请注明出处:https://www.huoxiaoqiang.com/php/symfony/6334.html

发表评论

登录后才能评论