[symfony]app:routesコマンド
Jobeet(Practical symfony)の5日目にあった、ルートのデバッグをするためのコマンドが、app:routesコマンドです。
./symfony app:routes application [name]
試しにJobeetの5日目の状態で「./symfony app:routes frontend」をたたくとこんな感じです。
TEXT:
-
$ ./symfony app:routes frontend
-
>> app Current routes for application "frontend"
-
Name Method Pattern
-
job GET /job.:sf_format
-
job_new GET /job/new.:sf_format
-
job_create POST /job.:sf_format
-
job_edit GET /job/:id/edit.:sf_format
-
job_update PUT /job/:id.:sf_format
-
job_delete DELETE /job/:id.:sf_format
-
job_show GET /job/:id.:sf_format
-
job_show_user GET /job/:company_slug/:location_slug/:id/:position_slug
-
homepage ANY /
-
default_index ANY /:module
-
default ANY /:module/:action/*
お決まりのdefaultルートに対して、「./symfony app:routes frontend default」をたたくとこんな感じです。
TEXT:
-
$ ./symfony app:routes frontend default
-
>> app Route "default" for application "frontend"
-
Name default
-
Pattern /:module/:action/*
-
Class sfRoute
-
Defaults
-
Requirements action: '[^/\\.]+'
-
module: '[^/\\.]+'
-
Options cache: NULL
-
context: array ()
-
debug: true
-
default_action: 'index'
-
default_module: 'default'
-
extra_parameters_as_query_string: true
-
generate_shortest_url: true
-
lazy_routes_deserialize: false
-
load_configuration: false
-
logging: false
-
lookup_cache_dedicated_keys: false
-
segment_separators: array (0 => '/',1 => '.',)
-
segment_separators_regex: '(?:/|\\.)'
-
suffix: ''
-
text_regex: '.+?'
-
variable_content_regex: '[^/\\.]+'
-
variable_prefix_regex: '(?:\\:)'
-
variable_prefixes: array (0 => ':',)
-
variable_regex: '[\\w\\d_]+'
-
Regex #^
-
/(?P<module>[^/\.]+)
-
/(?P<action>[^/\.]+)
-
(?:(?:/(?P<_star>.*))?
-
)?
-
$#x
-
Tokens separator array (0 => '/',1 => NULL,)
-
variable array (0 => ':module',1 => 'module',)
-
separator array (0 => '/',1 => NULL,)
-
variable array (0 => ':action',1 => 'action',)
-
separator array (0 => '/',1 => NULL,)
-
text array (0 => '*',1 => NULL,)
そしてsfPropelRouteCollectionによる自動生成ルートの1つに対して「./symfony app:routes frontend job_edit」をたたくとこんな感じです。
TEXT:
-
$ ./symfony app:routes frontend job_edit
-
>> app Route "job_edit" for application "frontend"
-
Name job_edit
-
Pattern /job/:id/edit.:sf_format
-
Class sfPropelRoute
-
Defaults action: 'edit'
-
module: 'job'
-
sf_format: 'html'
-
Requirements id: '\\d+'
-
sf_format: '[^/\\.]+'
-
sf_method: array (0 => 'get',)
-
Options cache: NULL
-
context: array ()
-
debug: true
-
default_action: 'index'
-
default_module: 'default'
-
extra_parameters_as_query_string: true
-
generate_shortest_url: true
-
lazy_routes_deserialize: false
-
load_configuration: false
-
logging: false
-
lookup_cache_dedicated_keys: false
-
method: NULL
-
model: 'JobeetJobPeer'
-
object_model: 'JobeetJob'
-
segment_separators: array (0 => '/',1 => '.',)
-
segment_separators_regex: '(?:/|\\.)'
-
suffix: ''
-
text_regex: '.+?'
-
type: 'object'
-
variable_content_regex: '[^/\\.]+'
-
variable_prefix_regex: '(?:\\:)'
-
variable_prefixes: array (0 => ':',)
-
variable_regex: '[\\w\\d_]+'
-
Regex #^
-
/job
-
/(?P<id>\d+)
-
/edit
-
(?:\.(?P<sf_format>[^/\.]+)
-
)?
-
$#x
-
Tokens separator array (0 => '/',1 => NULL,)
-
text array (0 => 'job',1 => NULL,)
-
separator array (0 => '/',1 => NULL,)
-
variable array (0 => ':id',1 => 'id',)
-
separator array (0 => '/',1 => NULL,)
-
text array (0 => 'edit',1 => NULL,)
-
separator array (0 => '.',1 => NULL,)
-
variable array (0 => ':sf_format',1 => 'sf_format',)
あまりに細かすぎて謎な感じですが、私が使うとしたら、詳細表示の末尾のTokensセクションにて、セパレータ文字が有効かどうかを確認するくらいでしょうか。以前セパレータに「_」を使ったらセパレータとして認識されなかったことがあったので、悩んだ末に「.」に変更したのですが、もしかしたらそこで使えたのかもしれません。