-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
flextype.php
executable file
·67 lines (51 loc) · 1.67 KB
/
flextype.php
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
<?php
declare(strict_types=1);
/**
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
namespace Flextype;
use Flextype\Foundation\Flextype;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
use Slim\Middleware\ContentLengthMiddleware;
use Slim\Middleware\OutputBufferingMiddleware;
use Slim\Middleware\RoutingMiddleware;
use Slim\Psr7\Factory\StreamFactory;
use Atomastic\Csrf\Csrf;
use Atomastic\Registry\Registry;
use Atomastic\Session\Session;
use Cocur\Slugify\Slugify;
use DateTimeZone;
/**
* Get Flextype Instance
*/
$flextype = flextype();
/**
* Set Flextype base path
*/
flextype()->app()->setBasePath('/flextype');
flextype()->app()->add(new RoutingMiddleware(flextype()->app()->getRouteResolver(), flextype()->app()->getRouteCollector()->getRouteParser()));
flextype()->app()->add(new ContentLengthMiddleware());
flextype()->app()->add(new OutputBufferingMiddleware(new StreamFactory(), OutputBufferingMiddleware::APPEND));
/**
* Init Registry
*/
flextype()->container()->set('registry', registry());
/**
* Init Actions
*/
flextype()->container()->set('actions', actions());
/**
* Preflight the Flextype
*/
include_once ROOT_DIR . '/src/flextype/preflight.php';
flextype()->app()->get('/hello/{name}', function ($name, Request $request, Response $response) {
$response->getBody()->write('Hello' . $name);
return $response;
})->setName('root');
flextype()->app()->getRouteCollector()->setCacheFile(PATH['tmp'] . '/routes.php');
flextype()->app()->addErrorMiddleware(true, true, true);
// Run flextype
flextype()->app()->run();