Php/laravel/laravel5/helloworld
提供: 初心者エンジニアの簡易メモ
2016年8月3日 (水) 19:16時点におけるAdmin (トーク | 投稿記録)による版 (ページの作成:「それぞれttp://localhost/helloでアクセスするとhelloworldと表示される ==ルーターでhelloworld== vi app/Http/routes.php Route::get('/hello', function...」)
それぞれ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>
