1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

cakephp3のresources、mapを使ったルーティング書き方例

Posted at
$routes->resources('User', [ // Userはコントローラー名
            'map' => [ // 設定したルートを複数指定出来る
                'get-profile' => [
                    'action' => 'getProfile', // 実行するメソッド名
                    'method' => 'GET',
                    'path' => 'get-profile/:userId', // url (:userIdは動的に値を渡す場合に指定)
                ],
                'login' => [
                    'action' => 'login',
                    'method' => 'POST',
                    'path' => 'login'
                ]
            ],
            'only' => ['get-profile', 'login'], // resourcesを使っている場合メソッドを限定する
            'connectOptions' => ['pass' => ['userId']] // connectメソッドの場合のsetPass等の値をここで設定出来る
        ]);
$routes->connect(・・・)->setPass(・・・);

みたいなのをresourcesでどう設定するんだろう、と思ってたけど、connectOptionsが使えるんやね。

以上。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?