Advertisement
Guest User

Untitled

a guest
Nov 12th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2.  
  3. header('Content-Type: text/html; charset=utf-8');
  4.  
  5. require_once 'Sparkle.php';
  6. require_once 'vendor/autoload.php';
  7.  
  8. $config = [
  9.     "path"  => "/framework/micro",
  10.     "views" => "views",
  11.     "dev"   => true
  12. ];
  13.  
  14. $app = new Sparkle\Application($config);
  15.  
  16. function hello($app, $params)
  17. {
  18.     return $app->render('hello.twig', ['name' => $params['name']]);
  19. }
  20.  
  21. class PagesController extends Sparkle\Controller
  22. {
  23.     public function hello($params)
  24.     {
  25.         extract($params);
  26.         return $this->app->render('hello.twig', ['name' => $name]);
  27.     }
  28. }
  29.  
  30. $app->router->get('/', function($app)
  31. {
  32.     return 'Sparkles!';
  33. });
  34.  
  35. $app->router->get('/test', function($app)
  36. {
  37.     $book = new Sparkle\Model($app);
  38.     $book->author = 'Somber';
  39.     $book->name = 'Project Horizons';
  40.  
  41.     return var_dump($book->data);
  42. });
  43.  
  44. $app->router->get('/hello/{name}', 'PagesController@hello');
  45.  
  46. $app->error(404, function($app)
  47. {
  48.     return 'Page does not exist';
  49. });
  50.  
  51. $app->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement