Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: text/html; charset=utf-8');
- require_once 'Sparkle.php';
- require_once 'vendor/autoload.php';
- $config = [
- "path" => "/framework/micro",
- "views" => "views",
- "dev" => true
- ];
- $app = new Sparkle\Application($config);
- function hello($app, $params)
- {
- return $app->render('hello.twig', ['name' => $params['name']]);
- }
- class PagesController extends Sparkle\Controller
- {
- public function hello($params)
- {
- extract($params);
- return $this->app->render('hello.twig', ['name' => $name]);
- }
- }
- $app->router->get('/', function($app)
- {
- return 'Sparkles!';
- });
- $app->router->get('/test', function($app)
- {
- $book = new Sparkle\Model($app);
- $book->author = 'Somber';
- $book->name = 'Project Horizons';
- return var_dump($book->data);
- });
- $app->router->get('/hello/{name}', 'PagesController@hello');
- $app->error(404, function($app)
- {
- return 'Page does not exist';
- });
- $app->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement