Created
September 30, 2014 22:26
-
-
Save malgorath/29f420d05174dbc0adea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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