Skip to content

Instantly share code, notes, and snippets.

@malgorath
Created September 30, 2014 22:26
Show Gist options
  • Save malgorath/29f420d05174dbc0adea to your computer and use it in GitHub Desktop.
Save malgorath/29f420d05174dbc0adea to your computer and use it in GitHub Desktop.
<?php
namespace App;
class HomeController {
private $app;
public function __construct() {
$this->app = \Slim\Slim::getInstance();
}
public function index () {
$this->app->view->render('index.html');
}
public function viewUser($id) {
echo "Welcome User ID: $id";
}
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
This is a test
<h3>And only a test</h3>
</body>
</html>
<?php
require '../vendor/autoload.php';
$app = new \Slim\Slim(array(
'debug' => true,
'view' => new \Slim\Views\Twig(),
'templates.path' => '../templates/',
));
$view = $app->view();
$view->parserOptions = array(
'debug' => true,
'cache' => '../cache'
);
$view->parserExtensions = array(
new \Slim\Views\TwigExtension(),
);
$app->get('/', 'App\HomeController:index');
$app->get('/users/:id', 'App\HomeController:viewUser');
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment