-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.php
59 lines (47 loc) · 1.32 KB
/
server.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
<?php
/*
* This is the server side of the ClimbUI application. It is a simple PHP script that
* extends from the Server class defined in the Service layer
*/
namespace ClimbUI;
use Exception;
// Needed for apache2 servers
// try {
// ob_flush();
// } catch (Exception $e) {
// }
// disable errors
error_reporting(0);
require_once __DIR__ . '/support/lib/vendor/autoload.php';
use \Approach\Service\format;
use \Approach\Service\target;
use \Approach\path;
use \Approach\Scope;
use \ClimbUI\Service\Server;
$path_to_project = __DIR__ . '/';
$path_to_approach = __DIR__ . '/support/lib/approach/';
$path_to_support = __DIR__ . '//support//';
// Defining a global scope for the application
global $scope;
$scope = new Scope(
path: [
path::project->value => $path_to_project,
path::installed->value => $path_to_approach,
path::support->value => $path_to_support,
],
);
// The php://input stream is needed apache2,
// but essentially for now, we are explicitly using post-requests
// So, any get requests will be ignored
$service = new Server(
auto_dispatch: false,
format_in: format::json,
format_out: format::json,
target_in: target::variable,
target_out: target::stream,
input: [
$_POST['json']
],
output: ['php://output'],
);
$output = $service->dispatch();