Skip to content

Commit a802674

Browse files
committed
first commit
0 parents  commit a802674

File tree

4 files changed

+234
-0
lines changed

4 files changed

+234
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
.buildpath
3+
.project
4+
.settings/
5+
vendor/

composer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name" : "phpmv/ubiquity-swoole",
3+
"description" : "swoole extension for Ubiquity framework",
4+
"type" : "extension",
5+
"keywords" : [
6+
"php",
7+
"framework",
8+
"mvc",
9+
"orm",
10+
"server",
11+
"swoole"
12+
],
13+
"require" : {
14+
"php" : ">7.0",
15+
"phpmv/ubiquity": "dev-master",
16+
"upscale/swoole-session": "^1.0"
17+
},
18+
"license" : "Apache-2.0",
19+
"authors" : [{
20+
"name" : "Jean-Christophe HERON",
21+
"email" : "myaddressmail@gmail.com",
22+
"role" : "Lead developer"
23+
}
24+
],
25+
"autoload" : {
26+
"psr-4" : {
27+
"Ubiquity\\" : "src/Ubiquity/"
28+
}
29+
},
30+
"extra" : {
31+
"branch-alias" : {
32+
"dev-master" : "1.0.x-dev"
33+
}
34+
},
35+
"require-dev" : {
36+
"swoole/ide-helper": "~4.3.3"
37+
}
38+
}

composer.lock

Lines changed: 156 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
namespace Ubiquity\servers;
3+
4+
use Swoole\Http\Server;
5+
use Swoole\Http\Request;
6+
use Swoole\Http\Response;
7+
8+
class SwooleServer {
9+
10+
private $server;
11+
12+
private $config;
13+
14+
private $basedir;
15+
16+
public function init($config, $basedir) {
17+
$this->config = $config;
18+
$this->basedir = $basedir;
19+
}
20+
21+
public function run($host, $port) {
22+
$http = new Server($host, $port);
23+
$http->on('start', function ($server) use ($host, $port) {
24+
echo "Ubiquity-Swoole http server is started at {$host}:{$port}\n";
25+
});
26+
27+
$http->on("request", function (Request $request, Response $response) {
28+
$response->header("Content-Type", "text/plain");
29+
$response->end("Hello World\n");
30+
});
31+
32+
$http->start();
33+
}
34+
}
35+

0 commit comments

Comments
 (0)