-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
77 lines (63 loc) · 1.93 KB
/
index.php
File metadata and controls
77 lines (63 loc) · 1.93 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
session_start();
set_time_limit(300);
/**
* Step 1: Require the Slim Framework using Composer's autoloader
*
* If you are not using Composer, you need to load Slim Framework with your own
* PSR-4 autoloader.
*/
require __DIR__ . '/vendor/autoload.php';
use Slim\App;
use Slim\Views\PhpRenderer;
use Numerate\controllers;
$container = new \Slim\Container;
$container['settings']['displayErrorDetails'] = true;
// Define DI in container
$container['view'] = function() {
return new PhpRenderer('app/templates/');
};
$container['WelcomeController'] = function($c) {
return new controllers\WelcomeController($c['view']);
};
$container['SampleController'] = function($c) {
return new controllers\SampleController($c['view']);
};
$container['EditorController'] = function($c) {
return new controllers\EditorController($c['view']);
};
/**
* Step 2: Instantiate a Slim application
*
* This example instantiates a Slim application using
* its default settings. However, you will usually configure
* your Slim application now by passing an associative array
* of setting names and values into the application constructor.
*/
$app = new Slim\App($container);
/* ================================================================================= */
/**
* Step 2.1:
*
* Define Slim containers
*
*
*/
/**
* Step 3: Define the Slim application routes
*
* Here we define several Slim application routes that respond
* to appropriate HTTP request methods. In this example, the second
* argument for `Slim::get`, `Slim::post`, `Slim::put`, `Slim::patch`, and `Slim::delete`
* is an anonymous function.
*/
$app->get('/', "WelcomeController:index");
$app->get('/sample', "SampleController:index");
$app->post('/editor', "EditorController:post");
/**
* Step 4: Run the Slim application
*
* This method should be called last. This executes the Slim application
* and returns the HTTP response to the HTTP client.
*/
$app->run();