[symfony]app:routesコマンド

カテゴリ: php,symfony / author: uechoco / 2009年12月21日 23:35:18
この記事を読む時間:1121くらい

Jobeet(Practical symfony)の5日目にあった、ルートのデバッグをするためのコマンドが、app:routesコマンドです。

./symfony app:routes application [name]

試しにJobeetの5日目の状態で「./symfony app:routes frontend」をたたくとこんな感じです。

TEXT:
  1. $ ./symfony app:routes frontend
  2. >> app       Current routes for application "frontend"
  3. Name          Method Pattern
  4. job           GET    /job.:sf_format
  5. job_new       GET    /job/new.:sf_format
  6. job_create    POST   /job.:sf_format
  7. job_edit      GET    /job/:id/edit.:sf_format
  8. job_update    PUT    /job/:id.:sf_format
  9. job_delete    DELETE /job/:id.:sf_format
  10. job_show      GET    /job/:id.:sf_format
  11. job_show_user GET    /job/:company_slug/:location_slug/:id/:position_slug
  12. homepage      ANY    /
  13. default_index ANY    /:module
  14. default       ANY    /:module/:action/*

お決まりのdefaultルートに対して、「./symfony app:routes frontend default」をたたくとこんな感じです。

TEXT:
  1. $ ./symfony app:routes frontend default
  2. >> app       Route "default" for application "frontend"
  3. Name         default
  4. Pattern      /:module/:action/*
  5. Class        sfRoute
  6. Defaults    
  7. Requirements action: '[^/\\.]+'
  8.              module: '[^/\\.]+'
  9. Options      cache: NULL
  10.              context: array ()
  11.              debug: true
  12.              default_action: 'index'
  13.              default_module: 'default'
  14.              extra_parameters_as_query_string: true
  15.              generate_shortest_url: true
  16.              lazy_routes_deserialize: false
  17.              load_configuration: false
  18.              logging: false
  19.              lookup_cache_dedicated_keys: false
  20.              segment_separators: array (0 => '/',1 => '.',)
  21.              segment_separators_regex: '(?:/|\\.)'
  22.              suffix: ''
  23.              text_regex: '.+?'
  24.              variable_content_regex: '[^/\\.]+'
  25.              variable_prefix_regex: '(?:\\:)'
  26.              variable_prefixes: array (0 => ':',)
  27.              variable_regex: '[\\w\\d_]+'
  28. Regex        #^
  29.              /(?P<module>[^/\.]+)
  30.              /(?P<action>[^/\.]+)
  31.              (?:(?:/(?P<_star>.*))?
  32.              )?
  33.              $#x
  34. Tokens       separator  array (0 => '/',1 => NULL,)
  35.              variable   array (0 => ':module',1 => 'module',)
  36.              separator  array (0 => '/',1 => NULL,)
  37.              variable   array (0 => ':action',1 => 'action',)
  38.              separator  array (0 => '/',1 => NULL,)
  39.              text       array (0 => '*',1 => NULL,)

そしてsfPropelRouteCollectionによる自動生成ルートの1つに対して「./symfony app:routes frontend job_edit」をたたくとこんな感じです。

TEXT:
  1. $ ./symfony app:routes frontend job_edit
  2. >> app       Route "job_edit" for application "frontend"
  3. Name         job_edit
  4. Pattern      /job/:id/edit.:sf_format
  5. Class        sfPropelRoute
  6. Defaults     action: 'edit'
  7.              module: 'job'
  8.              sf_format: 'html'
  9. Requirements id: '\\d+'
  10.              sf_format: '[^/\\.]+'
  11.              sf_method: array (0 => 'get',)
  12. Options      cache: NULL
  13.              context: array ()
  14.              debug: true
  15.              default_action: 'index'
  16.              default_module: 'default'
  17.              extra_parameters_as_query_string: true
  18.              generate_shortest_url: true
  19.              lazy_routes_deserialize: false
  20.              load_configuration: false
  21.              logging: false
  22.              lookup_cache_dedicated_keys: false
  23.              method: NULL
  24.              model: 'JobeetJobPeer'
  25.              object_model: 'JobeetJob'
  26.              segment_separators: array (0 => '/',1 => '.',)
  27.              segment_separators_regex: '(?:/|\\.)'
  28.              suffix: ''
  29.              text_regex: '.+?'
  30.              type: 'object'
  31.              variable_content_regex: '[^/\\.]+'
  32.              variable_prefix_regex: '(?:\\:)'
  33.              variable_prefixes: array (0 => ':',)
  34.              variable_regex: '[\\w\\d_]+'
  35. Regex        #^
  36.              /job
  37.              /(?P<id>\d+)
  38.              /edit
  39.              (?:\.(?P<sf_format>[^/\.]+)
  40.              )?
  41.              $#x
  42. Tokens       separator  array (0 => '/',1 => NULL,)
  43.              text       array (0 => 'job',1 => NULL,)
  44.              separator  array (0 => '/',1 => NULL,)
  45.              variable   array (0 => ':id',1 => 'id',)
  46.              separator  array (0 => '/',1 => NULL,)
  47.              text       array (0 => 'edit',1 => NULL,)
  48.              separator  array (0 => '.',1 => NULL,)
  49.              variable   array (0 => ':sf_format',1 => 'sf_format',)

あまりに細かすぎて謎な感じですが、私が使うとしたら、詳細表示の末尾のTokensセクションにて、セパレータ文字が有効かどうかを確認するくらいでしょうか。以前セパレータに「_」を使ったらセパレータとして認識されなかったことがあったので、悩んだ末に「.」に変更したのですが、もしかしたらそこで使えたのかもしれません。


コメントはまだありません »

コメントはまだありません。

この投稿へのコメントの RSS フィード。 TrackBack URI

コメントする

Copyright © 2012 うえちょこ@ぼろぐ. WP Theme created by Web Top.