技术库 > Symfony

symfony命令行详解

技术库:tec.5lulu.com

from:tec.5lulu.com

./symfony list

语法:
symfony [选项] 任务名 [参数]

选项:
–dry-run -n Do a dry run without executing actions.
–help -H 显示帮助信息
–quiet -q Do not log messages to standard output.
–trace -t Turn on invoke/execute tracing, enable full backtrace.
–version -V 显示程序版本
可用的任务:
help 显示任务的帮助信息 (简写h)

list 列出任务

app:routes 显示一个应用程序当前的路由信息

cache:clear 清空缓存(简写cc, clear-cache)

configure:author 设置项目作者
configure:database 设置数据库 DSN

generate:app 初始化一个应用程序 (简写init-app)
generate:module 初始化一个模块 (简写init-module)
generate:project 初始化一个项目 (简写init-proj)
generate:task Creates a skeleton class for a new task

i18n:extract Extracts i18n strings from php files
i18n:find Finds non “i18n ready” strings in an application

log:clear 清空日志 (log-purge)
log:rotate Rotates an application log files (log-rotate)

plugin:add-channel 添加一个新的PEAR频道
plugin:install 安装一个插件 (简写plugin-install)
plugin:list 列出已安装的插件 (简写plugin-list)
plugin:publish-assets 将全部插件的web目录发布到项目的web目录下
plugin:uninstall 卸载一个插件 (plugin-uninstall)
plugin:upgrade 升级一个插件(plugin-upgrade)

project:clear-controllers Clears all non production environment controllers (clear-controllers)
project:deploy 发布一个项目到另外一台服务器 (sync)
project:disable 在指定环境下屏蔽一个应用程序 (disable)
project:enable 在指定环境下打开一个应用程序 (disable)
project:freeze 冻结 symfony 库文件 (简写freeze)
project:permissions 修改symfony项目目录的权限 (permissions, fix-perms)
project:unfreeze 解冻 symfony 库文件 (简写unfreeze)
project:upgrade1.1 将一个symfony项目升级到1.1
project:upgrade1.2 将一个symonfy项目从1.1升级到1.2

propel:build-all 生成model,form,生成sql语句并创建数据库 (propel-build-all)
propel:build-all-load 生成model,form,生成sql语句,创建数据库并插入初始数据 (propel-build-all-load)
propel:build-filters 根据当前的模型创建过滤器
propel:build-forms 根据当前的模型创建表单
propel:build-model 根据数据库结构创建模型 (propel-build-model)
propel:build-schema 根据数据库结构创建schema (propel-build-schema)
propel:build-sql 根据当前模型创建一个SQL (简写propel-build-sql)
propel:data-dump 导出数据到 fixtures directory (propel-dump-data)
propel:data-load 从fixtures directory载入数据 (propel-load-data)
propel:generate-admin 自动生成一个module的后台
propel:generate-module Generates a Propel module (propel-generate-crud, propel:generate-crud)
propel:generate-module-for-route Generates a Propel module for a route definition
propel:graphviz Generates a graphviz chart of current object model
propel:init-admin 初始化一个module后台(propel-init-admin)
propel:insert-sql Inserts SQL for current model (propel-insert-sql)
propel:schema-to-xml 根据schema.yml生成schema.xml (propel-convert-yml-schema)
propel:schema-to-yml 根据schema.xml生成schema.yml (propel-convert-xml-schema)

test:all 运行全部测试 (简写test-all)
test:coverage Outputs test code coverage
test:functional 运行全部功能测试 (简写test-functional)
test:unit 运行单元测试 (test-unit)

./symfony help app:routes

语法:
symfony app:routes application [name]

参数:
application The application name
name A route name

描述:
The app:routes displays the current routes for a given application:

./symfony app:routes frontend

./symfony help cc

语法:
symfony cache:clear [--app[="..."]] [--env[="..."]] [--type[="..."]]

别名: cc, clear-cache

选项:
–app The application name
–env The environment
–type The type (default: all)

描述:
The cache:clear task clears the symfony cache.

By default, it removes the cache for all available types, all applications,
and all environments.

You can restrict by type, application, or environment:

For example, to clear the frontend application cache:

./symfony cache:clear –app=frontend

To clear the cache for the prod environment for the frontend application:

./symfony cache:clear –app=frontend –env=prod

To clear the cache for all prod environments:

./symfony cache:clear –env=prod

To clear the config cache for all prod environments:

./symfony cache:clear –type=config –env=prod

The built-in types are: config, i18n, routing, module
and template.

./symfony help configure:author

语法:
symfony configure:author author

参数:
author The project author

描述:
The configure:author task configures the author for a project:

./symfony configure:author “Fabien Potencier <fabien.potencier@symfony-project.com>”

The author is used by the generates to pre-configure the PHPDoc header for each generated file.

The value is stored in [config/properties.ini].

./symfony help configure:database

语法:
symfony configure:database [--env[="..."]] [--name[="..."]] [--class[="..."]] [--app[="..."]] dsn [username] [password]

参数:
dsn The database dsn
username The database username (default: root)
password The database password

选项:
–env The environment (default: all)
–name The connection name (default: propel)
–class The database class name (default: sfPropelDatabase)
–app The application name

描述:
The configure:database task configures the database DSN
for a project:

./symfony configure:database mysql:host=localhost;dbname=example root mYsEcret

By default, the task change the configuration for all environment. If you want
to change the dsn for a specific environment, use the env option:

./symfony configure:database –env=dev mysql:host=localhost;dbname=example_dev root mYsEcret

To change the configuration for a specific application, use the app option:

./symfony configure:database –app=frontend mysql:host=localhost;dbname=example root mYsEcret

You can also specify the connection name and the database class name:

./symfony configure:database –name=main –class=sfDoctrineDatabase mysql:host=localhost;dbname=example root

WARNING: The propel.ini file is also updated when you use a Propel database
and configure for all environments with no app.

./symfony help generate:app

语法:
symfony generate:app [--escaping-strategy="..."] [--csrf-secret="..."] application

别名: init-app

参数:
application The application name

选项:
–escaping-strategy Output escaping strategy (default: )
–csrf-secret Secret to use for CSRF protection (default: )

描述:
The generate:app task creates the basic directory structure
for a new application in the current project:

./symfony generate:app frontend

This task also creates two front controller scripts in the
web/ directory:

web/%application%.php for the production environment
web/%application%_dev.php for the development environment

For the first application, the production environment script is named
index.php.

If an application with the same name already exists,
it throws a sfCommandException.

You can enable output escaping (to prevent XSS) by using the escaping-strategy option:

./symfony generate:app frontend –escaping-strategy=on

You can enable session token in forms (to prevent CSRF) by defining
a secret with the csrf-secret option:

./symfony generate:app frontend –csrf-secret=UniqueSecret

./symfony help generate:module

语法:
symfony generate:module application module

别名: init-module

参数:
application The application name
module The module name

描述:
The generate:module task creates the basic directory structure
for a new module in an existing application:

./symfony generate:module frontend article

The task can also change the author name found in the actions.class.php
if you have configure it in config/properties.ini:

[symfony]
name=blog
author=Fabien Potencier <fabien.potencier@sensio.com>

You can customize the default skeleton used by the task by creating a
%sf_data_dir%/skeleton/module directory.

The task also creates a functional test stub named
%sf_test_dir%/functional/%application%/%module%ActionsTest.class.php
that does not pass by default.

If a module with the same name already exists in the application,
it throws a sfCommandException.

./symfony help generate:project

用方法:
symfony generate:project name

别名: init-project

参数:
name The project name

描述:
The generate:project task creates the basic directory structure
for a new project in the current directory:

./symfony generate:project blog

If the current directory already contains a symfony project,
it throws a sfCommandException.

./symfony help generate:task

语法:
symfony generate:task [--dir="..."] [--use-database="..."] [--brief-description="..."] task_name

参数:
task_name The task name (can contain namespace)

选项:
–dir The directory to create the task in (default: lib/task)
–use-database Whether the task needs model initialization to access database (default: propel)
–brief-description A brief task description (appears in task list)

描述:
The generate:task creates a new sfTask class based on the name passed as
argument:

./symfony generate:task namespace:name

The namespaceNameTask.class.php skeleton task is created under the lib/task/
directory. Note that the namespace is optional.

If you want to create the file in another directory (relative to the project
root folder), pass it in the –dir option. This directory will be created
if it does not already exist.

./symfony generate:task namespace:name –dir=plugins/myPlugin/lib/task

If you want the task to default to a connection other than propel, provide
the name of this connection with the –use-database option:

./symfony generate:task namespace:name –use-database=main

The –use-database option can also be used to disable database
initialization in the generated task:

./symfony generate:task namespace:name –use-database=false

You can also specify a description:

./symfony generate:task namespace:name –brief-description=”Does interesting things”

./symfony help i18n:extract

语法:
symfony i18n:extract [--display-new] [--display-old] [--auto-save] [--auto-delete] application culture

参数:
application The application name
culture The target culture

选项:
–display-new Output all new found strings
–display-old Output all old strings
–auto-save Save the new strings
–auto-delete Delete old strings

描述:
The i18n:extract task extracts i18n strings from your project files
for the given application and target culture:

./symfony i18n:extract frontend fr

By default, the task only displays the number of new and old strings
it found in the current project.

If you want to display the new strings, use the –display-new option:

./symfony i18n:extract –display-new frontend fr

To save them in the i18n message catalogue, use the –auto-save option:

./symfony i18n:extract –auto-save frontend fr

If you want to display strings that are present in the i18n messages
catalogue but are not found in the application, use the
–display-old option:

./symfony i18n:extract –display-old frontend fr

To automatically delete old strings, use the –auto-delete but
be careful, especially if you have translations for plugins as they will
appear as old strings but they are not:

./symfony i18n:extract –auto-delete frontend fr

./symfony help i18n:find

语法:
symfony i18n:find [--env="..."] application

参数:
application The application name

选项:
–env The environment (default: dev)

描述:
The i18n:find task finds non internationalized strings embedded in templates:

./symfony i18n:find frontend

This task is able to find non internationalized strings in pure HTML and in PHP code:

Non i18n text

As the task returns all strings embedded in PHP, you can have some false positive (especially
if you use the string syntax for helper arguments).

./symfony help log:clear

语法:
symfony log:clear

别名: log-purge

描述:
The log:clear task clears all symfony log files:

./symfony log:clear

./symfony help log:rotate

语法:
symfony log:rotate [--history="..."] [--period="..."] application env

别名: log-rotate

参数:
application The application name
env The environment name

选项:
–history The maximum number of old log files to keep (default: 10)
–period The period in days (default: 7)

描述:
The log:rotate task rotates application log files for a given
environment:

./symfony log:rotate frontend dev

You can specify a period or a history option:

./symfony –history=10 –period=7 log:rotate frontend dev

./symfony help plugin:add-channel

语法:
symfony plugin:add-channel name

参数:
name The channel name

描述:
The plugin:add-channel task adds a new PEAR channel:

./symfony plugin:add-channel symfony.plugins.pear.example.com

./symfony help plugin:install

语法:
symfony plugin:install [--stability|-s="..."] [--release|-r="..."] [--channel|-c="..."] [--install_deps|-d] [--force-license] name

别名: plugin-install

参数:
name The plugin name

选项:
–stability (-s) The preferred stability (stable, beta, alpha)
–release (-r) The preferred version
–channel (-c) The PEAR channel name
–install_deps (-d) Whether to force installation of required dependencies
–force-license Whether to force installation even if the license is not MIT like

描述:
The plugin:install task installs a plugin:

./symfony plugin:install sfGuardPlugin

By default, it installs the latest stable release.

If you want to install a plugin that is not stable yet,
use the stability option:

./symfony plugin:install –stability=beta sfGuardPlugin
./symfony plugin:install -s beta sfGuardPlugin

You can also force the installation of a specific version:

./symfony plugin:install –release=1.0.0 sfGuardPlugin
./symfony plugin:install -r 1.0.0 sfGuardPlugin

To force installation of all required dependencies, use the install_deps flag:

./symfony plugin:install –install-deps sfGuardPlugin
./symfony plugin:install -d sfGuardPlugin

By default, the PEAR channel used is symfony-plugins
(plugins.symfony-project.org).

You can specify another channel with the channel option:

./symfony plugin:install –channel=mypearchannel sfGuardPlugin
./symfony plugin:install -c mypearchannel sfGuardPlugin

Or you can use the channel/package notation:

./symfony plugin:install mypearchannel/sfGuardPlugin

You can also install PEAR packages hosted on a website:

./symfony plugin:install http://somewhere.example.com/sfGuardPlugin-1.0.0.tgz

Or local PEAR packages:

./symfony plugin:install /home/fabien/plugins/sfGuardPlugin-1.0.0.tgz

If the plugin contains some web content (images, stylesheets or javascripts),
the task creates a %name% symbolic link for those assets under web/.
On Windows, the task copy all the files to the web/%name% directory.

./symfony help plugin:list

语法:
symfony plugin:list

别名: plugin-list

描述:
The plugin:list task lists all installed plugins:

./symfony plugin:list

It also gives the channel and version for each plugin.

./symfony help plugin:publish-assets

语法:
symfony plugin:publish-assets [--core-only] [--symfony-lib-dir="..."]

选项:
–core-only If set only core plugins will publish their assets
–symfony-lib-dir The symfony lib dir

描述:
The plugin:publish-assets task will publish web assets from all plugins.

./symfony plugin:publish-assets

In fact this will send the plugin.post_install event to each plugin.

./symfony help plugin:uninstall

语法:
symfony plugin:uninstall [--channel|-c="..."] [--install_deps|-d] name

别名: plugin-uninstall

参数:
name The plugin name

选项:
–channel (-c) The PEAR channel name
–install_deps (-d) Whether to force installation of dependencies

描述:
The plugin:uninstall task uninstalls a plugin:

./symfony plugin:uninstall sfGuardPlugin

The default channel is symfony.

You can also uninstall a plugin which has a different channel:

./symfony plugin:uninstall –channel=mypearchannel sfGuardPlugin

./symfony plugin:uninstall -c mypearchannel sfGuardPlugin

Or you can use the channel/package notation:

./symfony plugin:uninstall mypearchannel/sfGuardPlugin

You can get the PEAR channel name of a plugin by launching the
plugin:list] task.

If the plugin contains some web content (images, stylesheets or javascripts),
the task also removes the [web/%name% symbolic link (on *nix)
or directory (on Windows).

./symfony help plugin:upgrade

语法:
symfony plugin:upgrade [--stability|-s="..."] [--release|-r="..."] [--channel|-c="..."] name

别名: plugin-upgrade

参数:
name The plugin name

选项:
–stability (-s) The preferred stability (stable, beta, alpha)
–release (-r) The preferred version
–channel (-c) The PEAR channel name

描述:
The plugin:upgrade task tries to upgrade a plugin:

./symfony plugin:upgrade sfGuardPlugin

The default channel is symfony.

If the plugin contains some web content (images, stylesheets or javascripts),
the task also updates the web/%name% directory content on Windows.

See plugin:install for more information about the format of the plugin name and options.

./symfony help project:clear-controllers

语法:
symfony project:clear-controllers

别名: clear-controllers

描述:
The project:clear-controllers task clears all non production environment
controllers:

./symfony project:clear-controllers

You can use this task on a production server to remove all front
controller scripts except the production ones.

If you have two applications named frontend and backend,
you have four default controller scripts in web/:

index.php
frontend_dev.php
backend.php
backend_dev.php

After executing the project:clear-controllers task, two front
controller scripts are left in web/:

index.php
backend.php

Those two controllers are safe because debug mode and the web debug
toolbar are disabled.

./symfony help project:deploy

语法:
symfony project:deploy [--go] [--rsync-dir="..."] [--rsync-options[="..."]] server

别名: sync

参数:
server The server name

选项:
–go Do the deployment
–rsync-dir The directory where to look for rsync*.txt files (default: config)
–rsync-options To options to pass to the rsync executable (default: -azC –force –delete)

描述:
The project:deploy task deploys a project on a server:

./symfony project:deploy production

The server must be configured in config/properties.ini:

[production]
host=www.example.com
port=22
user=fabien
dir=/var/www/sfblog/
type=rsync

To automate the deployment, the task uses rsync over SSH.
You must configure SSH access with a key or configure the password
in config/properties.ini.

By default, the task is in dry-mode. To do a real deployment, you
must pass the –go option:

./symfony project:deploy –go production

Files and directories configured in config/rsync_exclude.txt are
not deployed:

.svn
/web/uploads/*
/cache/*
/log/*

You can also create a rsync.txt and rsync_include.txt files.

If you need to customize the rsync*.txt files based on the server,
you can pass a rsync-dir option:

./symfony project:deploy –go –rsync-dir=config/production production

Last, you can specify the options passed to the rsync executable, using the
rsync-options option (defaults are -azC):

./symfony project:deploy –go –rsync-options=avz

./symfony help project:disable

语法:
symfony project:disable application env

别名: disable

参数:
application The application name
env The environment name

描述:
The project:disable task disables an application for a specific environment:

./symfony project:disable frontend prod

./symfony help project:enable

语法:
symfony project:enable application env

别名: enable

参数:
application The application name
env The environment name

描述:
The project:enable task enables an application for a specific environment:

./symfony project:enable frontend prod

./symfony help project:freeze

语法:
symfony project:freeze symfony_data_dir

别名: freeze

参数:
symfony_data_dir The symfony data directory

描述:
The project:freeze task copies all the symfony core files to
the current project:

./symfony project:freeze /path/to/symfony/data/directory

The task takes a mandatory argument of the path to the symfony data
directory.

The task also changes config/config.php to switch to the
embedded symfony files.

./symfony help project:permissions

语法:
symfony project:permissions

别名: permissions, fix-perms

描述:
The project:permissions task fixes directory permissions:

./symfony project:permissions

./symfony help project:unfreeze

语法:
symfony project:unfreeze

别名: unfreeze

描述:
The project:unfreeze task removes all the symfony core files from
the current project:

./symfony project:unfreeze

The task also changes config/config.php to switch to the
old symfony files used before the project:freeze command was used.

./symfony help project:upgrade1.1

语法:
symfony project:upgrade1.1

描述:
The project:upgrade1.1 task upgrades a symfony project
based the 1.0 release to the 1.1 symfony release.

./symfony project:upgrade1.1

Please read the UPGRADE_TO_1_1 file to have information on what does this task.

./symfony help project:upgrade1.2

语法:
symfony project:upgrade1.2

描述:
The project:upgrade1.2 task upgrades a symfony project
based on the 1.1 release to the 1.2 symfony release.

./symfony project:upgrade1.2

Please read the UPGRADE_TO_1_2 file to have information on what does this task.

./symfony help propel:build-all

语法:
symfony propel:build-all [--application[="..."]] [--env="..."] [--connection="..."] [--no-confirmation] [--skip-forms|-F]