An Eloquent PHP Framework
Ryan Durham
Stage Right Labs
ryan at stagerightlabs dot com
Package Management for PHP
$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
$ composer create-project laravel/laravel your-project-name
app/storage
directory writeableapp/config
options: Database, Email, etcmod_rewrite
is enabled app/routes.php
// Application Routes
Route::get('/login', function()
{
return View::make('users.login');
});
// Resourceful Routes - Default CRUD Routes
Route::resource('groups', 'GroupController');
// Controller Routes - CRUD Routes + Anyting Else
Route::controller('users', 'UserController');
app/views/layouts/master.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>
@section('title')
</title>
<link rel="stylesheet" href="@{{ asset('css/bootstrap.min.css') }}">
<link rel="stylesheet" href="@{{ asset('css/bootstrap-theme.min.css') }}">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
</div>
<div class="container">
@yield('content')
</div>
</body>
</html>
app/views/users/login.blade.php
@extends('layouts.master')
@section('title', 'Log In')
@section('content')
<div class="row">
<div class="col-md-4 col-md-offset-4">
{{ Form::open(array('action' => 'UserController@login')) }}
<h2 class="form-signin-heading">Sign In</h2>
{{ Form::text('email', null, array('class' => 'form-control', 'placeholder' => 'Email', 'autofocus')) }}
{{ Form::password('password', array('class' => 'form-control', 'placeholder' => 'Password'))}}
{{ Form::submit('Sign In', array('class' => 'btn btn-primary'))}}
{{ Form::close() }}
</div>
</div>
@stop
app/controllers/UserController.php
class UserController extends BaseController {
public function getIndex()
{
return view('users.index')->with('users', User::all());
}
public function postLogin(Request $request)
{
$email = $request->input('email');
$password = $request->input('password');
if (Auth::attempt(['email' => $email, 'password' => $password]))
{
return redirect()->intended('dashboard');
}
return redirect('login');
}
}
ryan at stagerightlabs dot com