LoginSignup
5
4

More than 5 years have passed since last update.

CakePHP3.1で追加されたRoutes Shellを試してみた

Last updated at Posted at 2015-11-20

CakePHP3.1で追加されたRoutes Shellを試してみた

Routes Shell はroutesを複雑に作っている場合等、CLIからroutesが正常に動くかをテストするときに使います。

URL解析チェック

以下のコマンドを実行することで、どのroutesに一致して、どうparseされるかを確認できます。

php bin/cake.php routes check /hoges/edit/1

// routesには以下が設定してあります。
// $routes->connect('/hoges/:action/*', ['controller' => 'fugas']);

実行結果

2015-11-21_02h00_28.png

※Query Stringを含む場合はcheck対象のURLをダブルコーテーションで囲む必要があります。

php bin/cake.php routes check "/hoges/edit?key1=aaa&key2=bbb"

URL生成チェック

以下のコマンドを実行することで、どういうURLが生成されるかを確認することが出来ます。

php bin/cake.php routes generate controller:fugas action:edit 1

// routesには以下が設定してあります。
// $routes->connect('/hoges/:action/*', ['controller' => 'fugas']);

実行結果

> /hoges/edit/1
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4