「Php/laravel/laravel5/helloworld」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「それぞれttp://localhost/helloでアクセスするとhelloworldと表示される ==ルーターでhelloworld== vi app/Http/routes.php Route::get('/hello', function...」) |
(相違点なし)
|
2016年8月3日 (水) 19:16時点における版
それぞれttp://localhost/helloでアクセスするとhelloworldと表示される
ルーターでhelloworld
vi app/Http/routes.php
Route::get('/hello', function () {
return 'helloworld';
});
コントローラーでhelloworld
vi app/Http/routes.php
Route::get('/hello', 'HelloController@index');
vi app/Http/Controllers/HelloController.php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class HelloController extends Controller
{
public function index()
{
return 'helloworld';
}
}
ビューでhelloworld
vi app/Http/Controllers/HelloController.php
class HelloController extends Controller
{
public function index()
{
return view('hello.index')->with('title', 'helloworld');
}
}
vi resources/views/hello/index.blade.php
<h1>{{ $title }}</h1>
