Skip to content

Commit fe5bb6b

Browse files
committed
refactored app and added plugin architecture
Moved indexer.php to cli Added PluginCommand Splitted CLI and HTTP
1 parent d697b0b commit fe5bb6b

26 files changed

Lines changed: 778 additions & 350 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
vendor/
22
logs/
3+
composer.lock
4+
plugins.json

bin/cli

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
require(dirname(__DIR__) . "/vendor/autoload.php");
5+
6+
set_time_limit(0);
7+
ini_set('memory_limit', '2048M');
8+
ini_set('display_errors', 'stderr');
9+
10+
$arguments = [];
11+
$app = new \Application\CLI\App(false);
12+
$app->handle(array_slice($argv, 1), null, []);

bin/indexer.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

bin/server.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use React\Http\Response;
55
use React\Http\Request;
6+
use Application\HTTP\App;
67

78
define("ROOT", dirname(__DIR__));
89

@@ -13,23 +14,21 @@
1314
$port = 15155;
1415
$host = 'localhost';
1516

16-
foreach($argv AS $arg){
17-
if($arg === '--no-io'){
17+
foreach ($argv as $arg) {
18+
if ($arg === '--no-io') {
1819
$noFsIO = true;
19-
}
20-
elseif(strpos($arg, '=') !== false){
20+
} elseif (strpos($arg, '=') !== false) {
2121
list($name, $value) = explode('=', $arg);
22-
if($name === '--port'){
22+
if ($name === '--port') {
2323
$port = $value;
24-
}
25-
elseif($name === '--host'){
24+
} elseif ($name === '--host') {
2625
$host = $value;
2726
}
2827
}
2928
}
3029

3130
$app = new App($noFsIO);
32-
$handler = function ($request, Response $response) use ($app){
31+
$handler = function ($request, Response $response) use ($app) {
3332
$start = microtime(1);
3433
printf("%s %s\n", $request->getMethod(), $request->getPath());
3534
if($request->getMethod() !== 'POST'){
@@ -42,9 +41,13 @@
4241
$body->data = "";
4342
$body->receivedLength = 0;
4443
$body->dataLength = $headers['Content-Length'];
45-
$request->on("data", function($data) use (
46-
$request, $response, $app, $body, $start
47-
){
44+
$request->on("data", function ($data) use (
45+
$request,
46+
$response,
47+
$app,
48+
$body,
49+
$start
50+
) {
4851
$body->data .= $data;
4952
$body->receivedLength += strlen($data);
5053
if($body->receivedLength >= $body->dataLength){

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"monolog/monolog": "~1.13",
1616
"mnapoli/php-di": "~4.4",
1717
"react/react": "0.4.*",
18-
"phpdocumentor/reflection-docblock": "~2.0"
18+
"phpdocumentor/reflection-docblock": "~2.0",
19+
"symfony/event-dispatcher": "^2.6"
1920
},
2021
"require-dev": {
2122
"behat/behat": "~3.0",

composer.lock

Lines changed: 83 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)