keeping it small: getting to know the slim micro framework
TRANSCRIPT
![Page 1: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/1.jpg)
Keeping it smallGetting to know the Slim micro framework
@JeremyKendall
![Page 2: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/2.jpg)
Jeremy Kendall
![Page 3: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/3.jpg)
Jeremy Kendall
I love to code
![Page 4: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/4.jpg)
Jeremy Kendall
I love to code
I’m terribly forgetful
![Page 5: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/5.jpg)
Jeremy Kendall
I love to code
I’m terribly forgetful
I take pictures
![Page 6: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/6.jpg)
Jeremy Kendall
I love to code
I’m terribly forgetful
I take pictures
I work at OpenSky
![Page 7: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/7.jpg)
Micro framework?
![Page 8: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/8.jpg)
Micro framework?
Concise codebase
![Page 9: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/9.jpg)
Micro framework?
Concise codebase
Clear codebase
![Page 10: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/10.jpg)
Micro framework?
Concise codebase
Clear codebase
Addresses a small set of use cases
![Page 11: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/11.jpg)
Micro framework?
Concise codebase
Clear codebase
Addresses a small set of use cases
Addresses those use cases well
![Page 12: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/12.jpg)
What is Slim?
![Page 13: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/13.jpg)
What is Slim?
Inspired by Sinatra
![Page 14: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/14.jpg)
What is Slim?
Inspired by Sinatra
Favors cleanliness over terseness
![Page 15: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/15.jpg)
What is Slim?
Inspired by Sinatra
Favors cleanliness over terseness
Favors common cases over edge cases
![Page 16: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/16.jpg)
Installing Slim
![Page 17: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/17.jpg)
RTFM
![Page 18: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/18.jpg)
RTFM ;-)
![Page 19: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/19.jpg)
Don’t forget .htaccess!
RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [QSA,L]
http://docs.slimframework.com/pages/routing-url-rewriting/
![Page 20: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/20.jpg)
Hello world<?php
require '../vendor/autoload.php';
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) { echo "Hello, $name";});
$app->run();
![Page 21: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/21.jpg)
Hello world<?php
require '../vendor/autoload.php';
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) { echo "Hello, $name";});
$app->run();
![Page 22: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/22.jpg)
Hello world<?php
require '../vendor/autoload.php';
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) { echo "Hello, $name";});
$app->run();
![Page 23: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/23.jpg)
Hello world<?php
require '../vendor/autoload.php';
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) { echo "Hello, $name";});
$app->run();
![Page 24: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/24.jpg)
Hello world<?php
require '../vendor/autoload.php';
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) { echo "Hello, $name";});
$app->run();
![Page 25: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/25.jpg)
Let’s look at a Slim application
![Page 26: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/26.jpg)
Flaming Archer
![Page 27: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/27.jpg)
Flaming Archer
wat
![Page 28: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/28.jpg)
“Great repository names are short and memorable. Need inspiration? How about flaming-archer.”
![Page 29: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/29.jpg)
Flaming Archer
![Page 30: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/30.jpg)
Flaming ArcherPhoto 365 project
![Page 31: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/31.jpg)
Flaming ArcherPhoto 365 project
Built in 4 days (Saturday through Tuesday)
![Page 32: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/32.jpg)
Flaming ArcherPhoto 365 project
Built in 4 days (Saturday through Tuesday)
Basic application — a few bells, no whistles
![Page 33: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/33.jpg)
Flaming ArcherPhoto 365 project
Built in 4 days (Saturday through Tuesday)
Basic application — a few bells, no whistles
Routing
![Page 34: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/34.jpg)
Flaming ArcherPhoto 365 project
Built in 4 days (Saturday through Tuesday)
Basic application — a few bells, no whistles
Routing
Twig views
![Page 35: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/35.jpg)
Flaming ArcherPhoto 365 project
Built in 4 days (Saturday through Tuesday)
Basic application — a few bells, no whistles
Routing
Twig views
Middleware
![Page 36: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/36.jpg)
4 views
![Page 37: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/37.jpg)
![Page 38: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/38.jpg)
![Page 39: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/39.jpg)
![Page 40: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/40.jpg)
![Page 41: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/41.jpg)
phploc --exclude vendor,tests,templates .
phploc 1.6.4 by Sebastian Bergmann.
Directories: 7Files: 13
Lines of Code (LOC): 876 Cyclomatic Complexity / Lines of Code: 0.04Comment Lines of Code (CLOC): 272Non-Comment Lines of Code (NCLOC): 604
![Page 42: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/42.jpg)
Configuration
![Page 43: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/43.jpg)
return array( 'slim' => array( 'templates.path' => __DIR__ . '/templates', 'log.level' => 4, 'log.enabled' => true, 'log.writer' => new Slim\Extras\Log\DateTimeFileWriter( array( 'path' => __DIR__ . '/logs', 'name_format' => 'y-m-d' ) ) ), 'twig' => array( // . . . ), 'cookies' => array( // . . . ), 'flickr.api.key' => 'FLICKR API KEY', 'pdo' => array( // . . . ));
![Page 44: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/44.jpg)
return array( 'slim' => array( 'templates.path' => __DIR__ . '/templates', 'log.level' => 4, 'log.enabled' => true, 'log.writer' => new Slim\Extras\Log\DateTimeFileWriter( array( 'path' => __DIR__ . '/logs', 'name_format' => 'y-m-d' ) ) ), 'twig' => array( // . . . ), 'cookies' => array( // . . . ), 'flickr.api.key' => 'FLICKR API KEY', 'pdo' => array( // . . . ));
Slim
![Page 45: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/45.jpg)
return array( 'slim' => array( 'templates.path' => __DIR__ . '/templates', 'log.level' => 4, 'log.enabled' => true, 'log.writer' => new Slim\Extras\Log\DateTimeFileWriter( array( 'path' => __DIR__ . '/logs', 'name_format' => 'y-m-d' ) ) ), 'twig' => array( // . . . ), 'cookies' => array( // . . . ), 'flickr.api.key' => 'FLICKR API KEY', 'pdo' => array( // . . . ));
Slim
Views
![Page 46: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/46.jpg)
return array( 'slim' => array( 'templates.path' => __DIR__ . '/templates', 'log.level' => 4, 'log.enabled' => true, 'log.writer' => new Slim\Extras\Log\DateTimeFileWriter( array( 'path' => __DIR__ . '/logs', 'name_format' => 'y-m-d' ) ) ), 'twig' => array( // . . . ), 'cookies' => array( // . . . ), 'flickr.api.key' => 'FLICKR API KEY', 'pdo' => array( // . . . ));
Slim
Views
Cookies
![Page 47: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/47.jpg)
return array( 'slim' => array( 'templates.path' => __DIR__ . '/templates', 'log.level' => 4, 'log.enabled' => true, 'log.writer' => new Slim\Extras\Log\DateTimeFileWriter( array( 'path' => __DIR__ . '/logs', 'name_format' => 'y-m-d' ) ) ), 'twig' => array( // . . . ), 'cookies' => array( // . . . ), 'flickr.api.key' => 'FLICKR API KEY', 'pdo' => array( // . . . ));
Slim
Views
Cookies
My stuff
![Page 48: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/48.jpg)
$config = require_once __DIR__ . '/../config.php';
// Prepare app$app = new Slim\Slim($config['slim']);
![Page 49: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/49.jpg)
$config = require_once __DIR__ . '/../config.php';
// Prepare app$app = new Slim\Slim($config['slim']);
Config array goes here
![Page 50: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/50.jpg)
Routing
![Page 51: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/51.jpg)
Routing
$app->get('/', function () use ($app, $service) { $images = $service->findAll(); $app->render('index.html', array('images' => $images)); });
![Page 52: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/52.jpg)
Routing
$app->get('/', function () use ($app, $service) { $images = $service->findAll(); $app->render('index.html', array('images' => $images)); });
HTTP Method
![Page 53: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/53.jpg)
Routing
$app->get('/', function () use ($app, $service) { $images = $service->findAll(); $app->render('index.html', array('images' => $images)); });
HTTP Method Resource URI
![Page 54: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/54.jpg)
Routing
$app->get('/', function () use ($app, $service) { $images = $service->findAll(); $app->render('index.html', array('images' => $images)); });
HTTP Method Resource URI Anonymous Function
![Page 55: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/55.jpg)
Routing
$app->get('/', function () use ($app, $service) { $images = $service->findAll(); $app->render('index.html', array('images' => $images)); });
![Page 56: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/56.jpg)
Routing
$app->get('/', function () use ($app, $service) { $images = $service->findAll(); $app->render('index.html', array('images' => $images)); });
Grabs all the pics
![Page 57: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/57.jpg)
Routing
$app->get('/', function () use ($app, $service) { $images = $service->findAll(); $app->render('index.html', array('images' => $images)); });
Grabs all the pics
Passes array of image data to index.html
![Page 58: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/58.jpg)
GET
$app->get('/:day', function($day) use ($app, $service) { $image = $service->find($day); if (!$image) { $app->notFound(); }
$app->render('images.html', $image); })->conditions(array('day' => '([1-9]\d?|[12]\d\d|3[0-5]\d|36[0-6])'));
![Page 59: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/59.jpg)
GET
$app->get('/:day', function($day) use ($app, $service) { $image = $service->find($day); if (!$image) { $app->notFound(); }
$app->render('images.html', $image); })->conditions(array('day' => '([1-9]\d?|[12]\d\d|3[0-5]\d|36[0-6])'));
URL parameter
![Page 60: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/60.jpg)
GET
$app->get('/:day', function($day) use ($app, $service) { $image = $service->find($day); if (!$image) { $app->notFound(); }
$app->render('images.html', $image); })->conditions(array('day' => '([1-9]\d?|[12]\d\d|3[0-5]\d|36[0-6])'));
URL parameter... gets passed as an
argument
![Page 61: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/61.jpg)
GET
$app->get('/:day', function($day) use ($app, $service) { $image = $service->find($day); if (!$image) { $app->notFound(); }
$app->render('images.html', $image); })->conditions(array('day' => '([1-9]\d?|[12]\d\d|3[0-5]\d|36[0-6])'));
URL parameter... gets passed as an
argument
Condition
![Page 62: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/62.jpg)
GET
$app->get('/:day', function($day) use ($app, $service) { $image = $service->find($day); if (!$image) { $app->notFound(); }
$app->render('images.html', $image); })->conditions(array('day' => '([1-9]\d?|[12]\d\d|3[0-5]\d|36[0-6])'));
URL parameter... gets passed as an
argument
Condition 1 to 366
![Page 63: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/63.jpg)
GET
$app->get('/:day', function($day) use ($app, $service) { $image = $service->find($day); if (!$image) { $app->notFound(); }
$app->render('images.html', $image); })->conditions(array('day' => '([1-9]\d?|[12]\d\d|3[0-5]\d|36[0-6])'));
404!
![Page 64: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/64.jpg)
POST (with redirect)
$app->post('/admin/add-photo', function() use ($app, $service) { $data = $app->request()->post(); $service->save($data); $app->redirect('/admin'); });
![Page 65: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/65.jpg)
POST (with redirect)
$app->post('/admin/add-photo', function() use ($app, $service) { $data = $app->request()->post(); $service->save($data); $app->redirect('/admin'); });
$_POST data is in the request object
![Page 66: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/66.jpg)
POST (with redirect)
$app->post('/admin/add-photo', function() use ($app, $service) { $data = $app->request()->post(); $service->save($data); $app->redirect('/admin'); });
$_POST data is in the request object
302 Redirect
![Page 67: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/67.jpg)
Multiple methods
$app->map('/login', function() { // Login })->via('GET', 'POST');
![Page 68: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/68.jpg)
Multiple methods
$app->map('/login', function() { // Login })->via('GET', 'POST');
Not an HTTP Method
![Page 69: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/69.jpg)
Multiple methods
$app->map('/login', function() { // Login })->via('GET', 'POST');
Not an HTTP Method
via() is the awesome sauce
![Page 70: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/70.jpg)
Logging and flash messaging
![Page 71: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/71.jpg)
$app->post('/admin/clear-cache', function() use ($app) {
$log = $app->getLog(); $cleared = null; $clear = $app->request()->post('clear');
if ($clear == 1) { if (apc_clear_cache('user')) { $cleared = 'Cache was successfully cleared!'; } else { $cleared = 'Cache was not cleared!'; $log->error('Cache not cleared'); } }
$app->flash('cleared', $cleared); $app->redirect('/admin'); });
![Page 72: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/72.jpg)
$app->post('/admin/clear-cache', function() use ($app) {
$log = $app->getLog(); $cleared = null; $clear = $app->request()->post('clear');
if ($clear == 1) { if (apc_clear_cache('user')) { $cleared = 'Cache was successfully cleared!'; } else { $cleared = 'Cache was not cleared!'; $log->error('Cache not cleared'); } }
$app->flash('cleared', $cleared); $app->redirect('/admin'); });
Get the log from $app
![Page 73: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/73.jpg)
$app->post('/admin/clear-cache', function() use ($app) {
$log = $app->getLog(); $cleared = null; $clear = $app->request()->post('clear');
if ($clear == 1) { if (apc_clear_cache('user')) { $cleared = 'Cache was successfully cleared!'; } else { $cleared = 'Cache was not cleared!'; $log->error('Cache not cleared'); } }
$app->flash('cleared', $cleared); $app->redirect('/admin'); });
Get the log from $app
Error!
![Page 74: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/74.jpg)
$app->post('/admin/clear-cache', function() use ($app) {
$log = $app->getLog(); $cleared = null; $clear = $app->request()->post('clear');
if ($clear == 1) { if (apc_clear_cache('user')) { $cleared = 'Cache was successfully cleared!'; } else { $cleared = 'Cache was not cleared!'; $log->error('Cache not cleared'); } }
$app->flash('cleared', $cleared); $app->redirect('/admin'); });
Get the log from $app
Error!
Flash message available in the next request.
![Page 75: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/75.jpg)
Middleware
“. . . a Slim application can have middleware that may inspect, analyze, or modify the application environment, request, and response before and/or after the Slim application is invoked.”
http://docs.slimframework.com/pages/middleware-overview/
![Page 76: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/76.jpg)
Hooks
![Page 77: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/77.jpg)
slim.before
Hooks
![Page 78: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/78.jpg)
slim.before
slim.before.router
Hooks
![Page 79: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/79.jpg)
slim.before
slim.before.router
slim.before.dispatch
Hooks
![Page 80: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/80.jpg)
slim.before
slim.before.router
slim.before.dispatch
slim.after.dispatch
Hooks
![Page 81: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/81.jpg)
slim.before
slim.before.router
slim.before.dispatch
slim.after.dispatch
slim.after.router
Hooks
![Page 82: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/82.jpg)
slim.before
slim.before.router
slim.before.dispatch
slim.after.dispatch
slim.after.router
slim.after
Hooks
![Page 83: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/83.jpg)
slim.before
slim.before.router
slim.before.dispatch
slim.after.dispatch
slim.after.router
slim.after
Hooks
![Page 84: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/84.jpg)
class MyMiddleware extends \Slim\Middleware{ public function call() { //The Slim application $app = $this->app;
//The Environment object $env = $app->environment();
//The Request object $req = $app->request();
//The Response object $res = $app->response();
//Optionally call the next middleware $this->next->call(); }}
![Page 85: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/85.jpg)
class MyMiddleware extends \Slim\Middleware{ public function call() { //The Slim application $app = $this->app;
//The Environment object $env = $app->environment();
//The Request object $req = $app->request();
//The Response object $res = $app->response();
//Optionally call the next middleware $this->next->call(); }}
Extend this
![Page 86: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/86.jpg)
class MyMiddleware extends \Slim\Middleware{ public function call() { //The Slim application $app = $this->app;
//The Environment object $env = $app->environment();
//The Request object $req = $app->request();
//The Response object $res = $app->response();
//Optionally call the next middleware $this->next->call(); }}
Extend this
Define call()
![Page 87: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/87.jpg)
class MyMiddleware extends \Slim\Middleware{ public function call() { //The Slim application $app = $this->app;
//The Environment object $env = $app->environment();
//The Request object $req = $app->request();
//The Response object $res = $app->response();
//Optionally call the next middleware $this->next->call(); }}
Extend this
Define call()
Inspect, analyze, and modify!
![Page 88: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/88.jpg)
class MyMiddleware extends \Slim\Middleware{ public function call() { //The Slim application $app = $this->app;
//The Environment object $env = $app->environment();
//The Request object $req = $app->request();
//The Response object $res = $app->response();
//Optionally call the next middleware $this->next->call(); }}
Extend this
Define call()
On to the next!
Inspect, analyze, and modify!
![Page 89: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/89.jpg)
Middleware + Hooks = WIN
![Page 90: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/90.jpg)
Navigation example
![Page 91: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/91.jpg)
namespace Tsf\Middleware;
use \Zend\Authentication\AuthenticationService;
class Navigation extends \Slim\Middleware{
/** * @var \Zend\Authentication\AuthenticationService */ private $auth;
public function __construct(AuthenticationService $auth) { $this->auth = $auth; }
public function call() { // . . . }
}
![Page 92: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/92.jpg)
namespace Tsf\Middleware;
use \Zend\Authentication\AuthenticationService;
class Navigation extends \Slim\Middleware{
/** * @var \Zend\Authentication\AuthenticationService */ private $auth;
public function __construct(AuthenticationService $auth) { $this->auth = $auth; }
public function call() { // . . . }
}
extends
![Page 93: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/93.jpg)
namespace Tsf\Middleware;
use \Zend\Authentication\AuthenticationService;
class Navigation extends \Slim\Middleware{
/** * @var \Zend\Authentication\AuthenticationService */ private $auth;
public function __construct(AuthenticationService $auth) { $this->auth = $auth; }
public function call() { // . . . }
}
Constructor injection FTW
extends
![Page 94: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/94.jpg)
public function call(){ $app = $this->app; $auth = $this->auth; $req = $app->request();
$home = array('caption' => 'Home', 'href' => '/'); $admin = array('caption' => 'Admin', 'href' => '/admin'); $login = array('caption' => 'Login', 'href' => '/login'); $logout = array('caption' => 'Logout', 'href' => '/logout'); if ($auth->hasIdentity()) { $navigation = array($home, $admin, $logout); } else { $navigation = array($home, $login); }
// . . .}
![Page 95: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/95.jpg)
public function call(){ $app = $this->app; $auth = $this->auth; $req = $app->request();
$home = array('caption' => 'Home', 'href' => '/'); $admin = array('caption' => 'Admin', 'href' => '/admin'); $login = array('caption' => 'Login', 'href' => '/login'); $logout = array('caption' => 'Logout', 'href' => '/logout'); if ($auth->hasIdentity()) { $navigation = array($home, $admin, $logout); } else { $navigation = array($home, $login); }
// . . .}
Arrays of nav items
![Page 96: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/96.jpg)
public function call(){ $app = $this->app; $auth = $this->auth; $req = $app->request();
$home = array('caption' => 'Home', 'href' => '/'); $admin = array('caption' => 'Admin', 'href' => '/admin'); $login = array('caption' => 'Login', 'href' => '/login'); $logout = array('caption' => 'Logout', 'href' => '/logout'); if ($auth->hasIdentity()) { $navigation = array($home, $admin, $logout); } else { $navigation = array($home, $login); }
// . . .}
Arrays of nav items
Nav differs based on auth status
![Page 97: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/97.jpg)
public function call(){ // . . .
$this->app->hook('slim.before.router', function () use (...) {
foreach ($navigation as &$link) { if ($link['href'] == $req->getPath()) { $link['class'] = 'active'; } else { $link['class'] = ''; } }
$app->view() ->appendData(array('navigation' => $navigation)); } );
$this->next->call();}
![Page 98: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/98.jpg)
public function call(){ // . . .
$this->app->hook('slim.before.router', function () use (...) {
foreach ($navigation as &$link) { if ($link['href'] == $req->getPath()) { $link['class'] = 'active'; } else { $link['class'] = ''; } }
$app->view() ->appendData(array('navigation' => $navigation)); } );
$this->next->call();}
Delicious hook goodness
![Page 99: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/99.jpg)
public function call(){ // . . .
$this->app->hook('slim.before.router', function () use (...) {
foreach ($navigation as &$link) { if ($link['href'] == $req->getPath()) { $link['class'] = 'active'; } else { $link['class'] = ''; } }
$app->view() ->appendData(array('navigation' => $navigation)); } );
$this->next->call();}
Delicious hook goodness
Match dispatched path
![Page 100: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/100.jpg)
public function call(){ // . . .
$this->app->hook('slim.before.router', function () use (...) {
foreach ($navigation as &$link) { if ($link['href'] == $req->getPath()) { $link['class'] = 'active'; } else { $link['class'] = ''; } }
$app->view() ->appendData(array('navigation' => $navigation)); } );
$this->next->call();}
Delicious hook goodness
Match dispatched path
Append $navigation to
view
![Page 101: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/101.jpg)
public function call(){ // . . .
$this->app->hook('slim.before.router', function () use (...) {
foreach ($navigation as &$link) { if ($link['href'] == $req->getPath()) { $link['class'] = 'active'; } else { $link['class'] = ''; } }
$app->view() ->appendData(array('navigation' => $navigation)); } );
$this->next->call();}
Delicious hook goodness
Match dispatched path
Append $navigation to
viewOn to the next!
![Page 102: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/102.jpg)
Views
![Page 103: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/103.jpg)
Two great tastes that taste great together
![Page 104: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/104.jpg)
Twig
![Page 105: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/105.jpg)
Twig
Concise
![Page 106: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/106.jpg)
Twig
Concise
Template oriented
![Page 107: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/107.jpg)
Twig
Concise
Template oriented
Fast
![Page 108: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/108.jpg)
Twig
Concise
Template oriented
Fast
Multiple inheritance
![Page 109: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/109.jpg)
Twig
Concise
Template oriented
Fast
Multiple inheritance
Blocks
![Page 110: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/110.jpg)
Twig
Concise
Template oriented
Fast
Multiple inheritance
Blocks
Automatic escaping
![Page 111: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/111.jpg)
layout.html and
index.html
![Page 112: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/112.jpg)
layout.html
![Page 113: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/113.jpg)
<title>{% block page_title %} {% endblock %}</title>
![Page 114: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/114.jpg)
<ul class="nav"> {% for link in navigation %} <li class="{{link.class}}"> <a href="{{link.href}}">{{link.caption}}</a> </li> {% endfor %}</ul>
![Page 115: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/115.jpg)
<h1>365 Days of Photography</h1><h3>Photographer: Jeremy Kendall</h3>{% block content %} {% endblock %}<hr />
![Page 116: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/116.jpg)
index.html
![Page 117: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/117.jpg)
{% extends 'layout.html' %}
{% block page_title %}365.jeremykendall.net{% endblock %}
{% block content %}{% for image in images %}<div class="row"> <div class="span6"> <h2><a href="/{{image.day}}">{{image.day}}/365</a></h2> <p> <a href="/{{image.day}}"> <img src="{{image.sizes.size.5.source}}" /> </a> </p> <p>Posted {{image.posted|date("m/d/Y")}}</p> </div></div>{% else %}<p>No images in project</p>{% endfor %}{% endblock %}
![Page 118: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/118.jpg)
{% extends 'layout.html' %}
{% block page_title %}365.jeremykendall.net{% endblock %}
{% block content %}{% for image in images %}<div class="row"> <div class="span6"> <h2><a href="/{{image.day}}">{{image.day}}/365</a></h2> <p> <a href="/{{image.day}}"> <img src="{{image.sizes.size.5.source}}" /> </a> </p> <p>Posted {{image.posted|date("m/d/Y")}}</p> </div></div>{% else %}<p>No images in project</p>{% endfor %}{% endblock %}
extends
![Page 119: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/119.jpg)
{% extends 'layout.html' %}
{% block page_title %}365.jeremykendall.net{% endblock %}
{% block content %}{% for image in images %}<div class="row"> <div class="span6"> <h2><a href="/{{image.day}}">{{image.day}}/365</a></h2> <p> <a href="/{{image.day}}"> <img src="{{image.sizes.size.5.source}}" /> </a> </p> <p>Posted {{image.posted|date("m/d/Y")}}</p> </div></div>{% else %}<p>No images in project</p>{% endfor %}{% endblock %}
extends
<title />
![Page 120: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/120.jpg)
{% extends 'layout.html' %}
{% block page_title %}365.jeremykendall.net{% endblock %}
{% block content %}{% for image in images %}<div class="row"> <div class="span6"> <h2><a href="/{{image.day}}">{{image.day}}/365</a></h2> <p> <a href="/{{image.day}}"> <img src="{{image.sizes.size.5.source}}" /> </a> </p> <p>Posted {{image.posted|date("m/d/Y")}}</p> </div></div>{% else %}<p>No images in project</p>{% endfor %}{% endblock %}
extends
<title />
![Page 121: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/121.jpg)
{% extends 'layout.html' %}
{% block page_title %}365.jeremykendall.net{% endblock %}
{% block content %}{% for image in images %}<div class="row"> <div class="span6"> <h2><a href="/{{image.day}}">{{image.day}}/365</a></h2> <p> <a href="/{{image.day}}"> <img src="{{image.sizes.size.5.source}}" /> </a> </p> <p>Posted {{image.posted|date("m/d/Y")}}</p> </div></div>{% else %}<p>No images in project</p>{% endfor %}{% endblock %}
extends
<title />iterator
![Page 122: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/122.jpg)
{% extends 'layout.html' %}
{% block page_title %}365.jeremykendall.net{% endblock %}
{% block content %}{% for image in images %}<div class="row"> <div class="span6"> <h2><a href="/{{image.day}}">{{image.day}}/365</a></h2> <p> <a href="/{{image.day}}"> <img src="{{image.sizes.size.5.source}}" /> </a> </p> <p>Posted {{image.posted|date("m/d/Y")}}</p> </div></div>{% else %}<p>No images in project</p>{% endfor %}{% endblock %}
extends
<title />iterator
else
![Page 123: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/123.jpg)
{% extends 'layout.html' %}
{% block page_title %}365.jeremykendall.net{% endblock %}
{% block content %}{% for image in images %}<div class="row"> <div class="span6"> <h2><a href="/{{image.day}}">{{image.day}}/365</a></h2> <p> <a href="/{{image.day}}"> <img src="{{image.sizes.size.5.source}}" /> </a> </p> <p>Posted {{image.posted|date("m/d/Y")}}</p> </div></div>{% else %}<p>No images in project</p>{% endfor %}{% endblock %}
extends
<title />iterator
elseformat
![Page 124: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/124.jpg)
login.html
![Page 125: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/125.jpg)
{% extends 'layout.html' %}
{% block page_title %}365.jeremykendall.net | Login{% endblock %}
{% block content %}<div class="row"> <div class="span4"> <h2>Login</h2> {% if flash.error %} <p style="color: red;">{{flash.error}}</p> {% endif %} <form name="login" id="login" class="well" method="post"> // Login form . . . </form> </div></div>
{% endblock %}
![Page 126: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/126.jpg)
{% extends 'layout.html' %}
{% block page_title %}365.jeremykendall.net | Login{% endblock %}
{% block content %}<div class="row"> <div class="span4"> <h2>Login</h2> {% if flash.error %} <p style="color: red;">{{flash.error}}</p> {% endif %} <form name="login" id="login" class="well" method="post"> // Login form . . . </form> </div></div>
{% endblock %}
![Page 127: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/127.jpg)
The other viewswould be redundant
![Page 128: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/128.jpg)
GOTO 0
![Page 129: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/129.jpg)
Small but powerfulGOTO 0
![Page 130: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/130.jpg)
Small but powerful
Excellent tools to write elegant code
GOTO 0
![Page 131: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/131.jpg)
Small but powerful
Excellent tools to write elegant code
Routing, middleware & hooks, views
GOTO 0
![Page 132: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/132.jpg)
Small but powerful
Excellent tools to write elegant code
Routing, middleware & hooks, views
I just scratched the surface
GOTO 0
![Page 133: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/133.jpg)
Read
Slim: slimframework.com
Twig: twig.sensiolabs.org
Composer: getcomposer.org
MicroPHP Manifesto: microphp.org
Flaming Archer: http://git.io/rH0nrg
![Page 134: Keeping it Small: Getting to know the Slim Micro Framework](https://reader033.vdocument.in/reader033/viewer/2022060110/555a07bcd8b42ad00a8b53d3/html5/thumbnails/134.jpg)
Questions?