PHP Laravel4でController on Ubuntu12.04 LTS
ルートの設定
app/routes.php
// UserControllerにshowProfileメソッドを追加する。
Route::get('user/{id}', 'UserController@showProfile');
Controllerの設定
app/controllers/UserController.php
<?php
class UserController extends BaseController {
/**
* Instantiate a new UserController instance.
*/
public function __construct()
{
Log::info('Start UserController: __construct');
}
/**
* 指定されたユーザーのプロファイルを表示する
*/
public function showProfile($id)
{
Log::info('Start IDs:'.$id);
// $user = User::find($id);
$name='Hoge';
Log::info(' name:'.$name);
return View::make('greeting', array('name' => $name));
}
}
Viewの設定
app/views/greeting.blade.php
<html>
<body>
<h1>こんにちは、{{{$name}}}さん</h1>
</body>
</html>
参考:
Laravel4 Controller 日本語版
Laravel4.1ドキュメント
- 関連記事
-
- VirtualBoxのインストール Ubuntu12.04 LTS
- PHP Laravel4でController on Ubuntu12.04 LTS
- PHP LaravelでJson on Ubuntu12.04 LTS