#
Views
Next, we'll create a simple view to display our user data. Views live in the app/views
directory and contain the HTML of your application. We're going to place two new views in this directory: layout.blade.php
and users.blade.php
. First, let's create our layout.blade.php
file:
<html>
<body>
<h1>Laravel Quickstart</h1>
@yield('content')
</body>
</html>
Next, we'll create our users.blade.php
view:
@extends('layout')
@section('content')
Users!
@stop
Some of this syntax probably looks quite strange to you. That's because we're using Laravel's templating system: Blade. Blade is very fast, because it is simply a handful of regular expressions that are run against your templates to compile them to pure PHP. Blade provides powerful functionality like template inheritance, as well as some syntax sugar on typical PHP control structures such as if
and for
. Check out the Blade documentation
for more details.
Now that we have our views, let's return it from our /users
route. Instead of returning Users!
from the route, return the view instead:
Route::get('users', function()
{
return View::make('users');
});
Wonderful! Now you have setup a simple view that extends a layout. Next, let's start working on our database layer.