-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.php
41 lines (30 loc) · 1.1 KB
/
index.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
<?php
/**
* PHP Rocker
* ---------------------------------
*
* @package rocker/server
* @author Victor Jonsson (http://victorjonsson.se)
* @license MIT license (http://opensource.org/licenses/MIT)
*/
// Composer class loader
require __DIR__.'/vendor/autoload.php';
// Load config
$config = require __DIR__.'/config.php';
// Initiate server
$server = new \Rocker\Server($config);
// Output the auto-generated documentation
$docsURI = $config['application.path'] == '/' ? '/docs':'/';
$server->get($docsURI, function() use($config, $server) {
$converter = new \Rocker\Utils\XML\ArrayConverter();
$generator = new \Rocker\REST\Documentation\Generator();
// Generate documentation and convert it to an array
$documentationXML = $generator->generateDocumentation($config['application.operations']);
// Add $documentation to current scope, later used in the template
$documentation = $converter->convertXMLToArray($documentationXML);
// Generate the documentation website
$template = $generator->getExampleTemplatePath();
require $template;
});
// Run forrest run
$server->run();