Skip to content

Instantly share code, notes, and snippets.

@violetyk
Last active December 17, 2015 09:39
Show Gist options
  • Save violetyk/5589293 to your computer and use it in GitHub Desktop.
Save violetyk/5589293 to your computer and use it in GitHub Desktop.
[cakephp]ルーティング
<?php
/*
* /posts/123 -> $id
*/
// routes.php
Router::connect('/posts/*', array('controller' => 'posts', 'action' => 'view'));
// PostsController
function view($id = null) {
}
// ----------
// routes.php
Router::connect('/posts/:id', array('controller' => 'posts', 'action' => 'view'), array('id' => '[0-9]+'));
// PostsController
function view() {
$id = $this->params['id'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment