私はcodeigniterから来ており、ルーティングに頭を悩ませようとしています。http://codehappy.daylerees.com/using-controllersチュートリアルに従ってい ます
下にスクロールしてRESTfulコントローラーに移動すると、DayleはHome_Controllerがbase_controllerを拡張し、パブリック関数get_index()とpost_index()を追加することについて話します。コードをコピーしましたが、
http://localhost/m1/public/account/superwelcome/Dayle/Wales
私は得る:
私たちは間違った方向に進んだ。サーバーエラー:404(見つかりません)。
私が間違っていることは明らかですか?コードを別の場所に配置する必要がありますか?これが私のコードです
class Base_Controller extends Controller {
/**
* Catch-all method for requests that can't be matched.
*
* @param string $method
* @param array $parameters
* @return Response
*/
public function __call($method, $parameters)
{
return Response::error('404');
}
public $restful = true;
public function get_index()
{
//
}
public function post_index()
{
//
}
}
私が持っているroutes.phpファイル:
// application/routes.php
Route::get('superwelcome/(:any)/(:any)', 'account@welcome');
私のアカウントコントローラー(チュートリアルから)は次のとおりです。
// application/controllers/account.php
class Account_Controller extends Base_Controller
{
public function action_index()
{
echo "This is the profile page.";
}
public function action_login()
{
echo "This is the login form.";
}
public function action_logout()
{
echo "This is the logout action.";
}
public function action_welcome($name, $place)
{
$data = array(
'name' => $name,
'place' => $place
);
return View::make('welcome', $data);
}
}