-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
47 lines (30 loc) · 806 Bytes
/
index.php
File metadata and controls
47 lines (30 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
require 'vendor/autoload.php';
class CustomView extends \Slim\View
{
public function render($template)
{
return $template;
}
};
// Crea la nueva aplicación
$app = new \Slim\Slim(array(
'view' => new CustomView()
));
// Añade las rutas
// Aquí hay un closure. Debemos usar la palabra reservada USE para añadir parámetros
// Externos!!!!
$app->get('/', function() use ($app) {
// Ahora, puedo usar $app dentro del closure!!!!
var_dump($app->request->isGet());
echo '<h1>Hola Maria!!!!!</h1>';
});
$app->get('/saludo/:person', function($person) {
// Usando parámetros
echo "Hola " . $person;
});
$app->get('/vista/', function() use ($app){
$app->render('<h1>template test</h1>');
});
// Inicia la aplicación
$app->run();