Oke, melanjutkan tutorial laravel sebelumnya..
Kali ini kita akan belajar struktur file pada laravel,
Aturan pembuatan struktur framework laravel: route-controller-view
- Route => disini tempat mengatur url dan link controller
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', 'HomeController@showWelcome');
Dengan begini kita sudah menautkan controller pada route.
Lihat pada gambar HomeController merupakan controller yang akan menampilkan halaman home dengan url "/". Sedangkan showWelcome merupakan class methodnya
- Controller => disini tempat membuat method yang akan ditampilkan pada view
<?php
class HomeController extends BaseController {
/*
|--------------------------------------------------------------------------
| Default Home Controller
|--------------------------------------------------------------------------
|
| You may wish to use controllers instead of, or in addition to, Closure
| based routes. That's great! Here is an example controller method to
| get you started. To route to this controller, just add the route:
|
| Route::get('/', 'HomeController@showWelcome');
|
*/
public function showWelcome()
{
return View::make('hello');
}
}
Dapat dilihat pada gambar controller Home mengarahkan route "/" ke halaman view hello
- View => disini tempat meletakkan interface website kita
<?php
return View::make('hello');
Sehingga pada saat kita membuka URL: localhost/(nama project) maka akan muncul
===DONE!!!===