Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 62e47c9

Browse files
authored
Merge pull request #188 from swooletw/develop
Develop
2 parents cbb9914 + d036c18 commit 62e47c9

File tree

113 files changed

+3897
-1166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3897
-1166
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.DS_Store
33
phpunit.xml
44
composer.lock
5+
.scannerwork
56

67
# Folders
78
vendor

.scrutinizer.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
build:
2+
environment:
3+
php: 7.2
4+
5+
filter:
6+
excluded_paths:
7+
- "tests/*"
8+
- "routes/*"
9+
- "config/*"
10+
- "stubs/*"
11+
dependency_paths:
12+
- "vendor/*"

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ sudo: false
44

55
matrix:
66
include:
7-
- php: 7.2
8-
env: FRAMEWORK_VERSION=laravel/framework:5.1.*
9-
- php: 7.2
10-
env: FRAMEWORK_VERSION=laravel/framework:5.2.*
117
- php: 7.2
128
env: FRAMEWORK_VERSION=laravel/framework:5.3.*
139
- php: 7.2
1410
env: FRAMEWORK_VERSION=laravel/framework:5.4.*
1511
- php: 7.2
1612
env: FRAMEWORK_VERSION=laravel/framework:5.5.*
1713
- php: 7.2
18-
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.1.*
14+
env: FRAMEWORK_VERSION=laravel/framework:5.6.*
1915
- php: 7.2
20-
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.2.*
16+
env: FRAMEWORK_VERSION=laravel/framework:5.7.*
2117
- php: 7.2
2218
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.3.*
2319
- php: 7.2
2420
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.4.*
2521
- php: 7.2
2622
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.5.*
23+
- php: 7.2
24+
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.6.*
25+
- php: 7.2
26+
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.7.*
2727

2828
before_install:
2929
- printf "\n" | pecl install swoole
@@ -37,4 +37,4 @@ script:
3737
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml
3838

3939
after_success:
40-
- vendor/bin/coveralls -v
40+
- vendor/bin/php-coveralls -v

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This package provides a high performance HTTP server to speed up your Laravel/Lu
1212

1313
| PHP | Laravel | Lumen | Swoole |
1414
|:-------:|:-------:|:-----:|:-------:|
15-
| >=7.1 | ~5.1 | ~5.1 | >=4.0.0 |
15+
| >=7.1 | ~5.3 | ~5.1 | >=4.0.0 |
1616

1717
## Features
1818

composer.json

Lines changed: 72 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,76 @@
11
{
2-
"name": "swooletw/laravel-swoole",
3-
"description": "High performance HTTP server based on Swoole. Speed up your Laravel and Lumen applications.",
4-
"keywords": ["swoole", "laravel", "lumen", "performance", "http", "server"],
5-
"license": "MIT",
6-
"authors": [
7-
{
8-
"name": "Albert Chen",
9-
"email": "[email protected]"
10-
},
11-
{
12-
"name": "Huang Yi",
13-
"email": "[email protected]"
14-
}
15-
],
16-
"require": {
17-
"php": "^7.1",
18-
"illuminate/console": "~5.1",
19-
"illuminate/contracts": "~5.1",
20-
"illuminate/http": "~5.1",
21-
"illuminate/support": "~5.1",
22-
"predis/predis": "^1.1"
23-
},
24-
"require-dev": {
25-
"laravel/lumen-framework": "~5.1",
26-
"phpunit/phpunit": "^6.1",
27-
"phpunit/php-code-coverage": "^5.2",
28-
"satooshi/php-coveralls": "^1.0",
29-
"mockery/mockery": "~1.0",
30-
"codedungeon/phpunit-result-printer": "^0.14.0",
31-
"php-mock/php-mock": "^2.0"
32-
},
33-
"autoload": {
34-
"files": [
35-
"src/Server/helpers.php"
36-
],
37-
"psr-4": {
38-
"SwooleTW\\Http\\": "src"
39-
}
40-
},
41-
"autoload-dev": {
42-
"psr-4": {
43-
"SwooleTW\\Http\\Tests\\": "tests",
44-
"SwooleTW\\Http\\Tests\\Fixtures\\Laravel\\App\\": "tests/fixtures/laravel/app"
45-
}
2+
"name": "swooletw/laravel-swoole",
3+
"description": "High performance HTTP server based on Swoole. Speed up your Laravel and Lumen applications.",
4+
"keywords": [
5+
"swoole",
6+
"laravel",
7+
"lumen",
8+
"performance",
9+
"http",
10+
"server"
11+
],
12+
"license": "MIT",
13+
"authors": [
14+
{
15+
"name": "Albert Chen",
16+
"email": "[email protected]"
4617
},
47-
"extra": {
48-
"laravel": {
49-
"providers": [
50-
"SwooleTW\\Http\\LaravelServiceProvider"
51-
],
52-
"aliases": {
53-
"Server": "SwooleTW\\Http\\Server\\Facades\\Server",
54-
"Table": "SwooleTW\\Http\\Server\\Facades\\Table",
55-
"Room": "SwooleTW\\Http\\Websocket\\Facades\\Room",
56-
"Websocket": "SwooleTW\\Http\\Websocket\\Facades\\Websocket"
57-
}
58-
}
18+
{
19+
"name": "Huang Yi",
20+
"email": "[email protected]"
21+
}
22+
],
23+
"require": {
24+
"php": "^7.2",
25+
"illuminate/console": "~5.3",
26+
"illuminate/contracts": "~5.3",
27+
"illuminate/http": "~5.3",
28+
"illuminate/support": "~5.3",
29+
"predis/predis": "^1.1",
30+
"ext-json": "*",
31+
"ext-fileinfo": "*",
32+
"ext-pdo": "*",
33+
"ext-pcntl": "*"
34+
},
35+
"require-dev": {
36+
"laravel/lumen-framework": "~5.3",
37+
"phpunit/phpunit": "^7.5",
38+
"phpunit/php-code-coverage": "^6.1",
39+
"php-coveralls/php-coveralls": "^2.1",
40+
"mockery/mockery": "~1.0",
41+
"codedungeon/phpunit-result-printer": "^0.14.0",
42+
"php-mock/php-mock": "^2.0"
43+
},
44+
"autoload": {
45+
"files": [
46+
"src/Server/helpers.php"
47+
],
48+
"psr-4": {
49+
"SwooleTW\\Http\\": "src"
50+
}
51+
},
52+
"autoload-dev": {
53+
"psr-4": {
54+
"SwooleTW\\Http\\Tests\\": "tests",
55+
"SwooleTW\\Http\\Tests\\Fixtures\\Laravel\\App\\": "tests/fixtures/laravel/app"
56+
}
57+
},
58+
"extra": {
59+
"laravel": {
60+
"providers": [
61+
"SwooleTW\\Http\\LaravelServiceProvider"
62+
],
63+
"aliases": {
64+
"Server": "SwooleTW\\Http\\Server\\Facades\\Server",
65+
"Table": "SwooleTW\\Http\\Server\\Facades\\Table",
66+
"Room": "SwooleTW\\Http\\Websocket\\Facades\\Room",
67+
"Websocket": "SwooleTW\\Http\\Websocket\\Facades\\Websocket"
68+
}
5969
}
70+
},
71+
"scripts": {
72+
"post-autoload-dump": [
73+
"@php copy_versioned_files.php"
74+
]
75+
}
6076
}

config/swoole_http.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
use Swoole\Table;
4-
53
return [
64
/*
75
|--------------------------------------------------------------------------
@@ -17,9 +15,11 @@
1715
'public_path' => base_path('public'),
1816
// Determine if to use swoole to respond request for static files
1917
'handle_static_files' => env('SWOOLE_HANDLE_STATIC', true),
18+
'access_log' => env('SWOOLE_HTTP_ACCESS_LOG', false),
2019
// You must add --enable-openssl while compiling Swoole
2120
// Put `SWOOLE_SOCK_TCP | SWOOLE_SSL` if you want to enable SSL
2221
'socket_type' => SWOOLE_SOCK_TCP,
22+
'process_type' => SWOOLE_PROCESS,
2323
'options' => [
2424
'pid_file' => env('SWOOLE_HTTP_PID_FILE', base_path('storage/logs/swoole_http.pid')),
2525
'log_file' => env('SWOOLE_HTTP_LOG_FILE', base_path('storage/logs/swoole_http.log')),
@@ -53,6 +53,19 @@
5353
'enabled' => env('SWOOLE_HTTP_WEBSOCKET', false),
5454
],
5555

56+
/*
57+
|--------------------------------------------------------------------------
58+
| Hot reload configuration
59+
|--------------------------------------------------------------------------
60+
*/
61+
'hot_reload' => [
62+
'enabled' => env('SWOOLE_HOT_RELOAD_ENABLE', false),
63+
'recursively' => env('SWOOLE_HOT_RELOAD_RECURSIVELY', true),
64+
'directory' => env('SWOOLE_HOT_RELOAD_DIRECTORY', base_path()),
65+
'log' => env('SWOOLE_HOT_RELOAD_LOG', true),
66+
'filter' => env('SWOOLE_HOT_RELOAD_FILTER', '.php'),
67+
],
68+
5669
/*
5770
|--------------------------------------------------------------------------
5871
| Console output will be transferred to response content if enabled.
@@ -120,5 +133,5 @@
120133
// ['name' => 'column_name', 'type' => Table::TYPE_STRING, 'size' => 1024],
121134
// ]
122135
// ],
123-
]
136+
],
124137
];

config/swoole_websocket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
'room_rows' => 4096,
7878
'room_size' => 2048,
7979
'client_rows' => 8192,
80-
'client_size' => 2048
80+
'client_size' => 2048,
8181
],
8282

8383
'redis' => [
@@ -92,6 +92,6 @@
9292
//
9393
],
9494
'prefix' => 'swoole:',
95-
]
95+
],
9696
],
9797
];

copy_versioned_files.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
require __DIR__.'/vendor/autoload.php';
4+
5+
use SwooleTW\Http\Coroutine\Connectors\ConnectorFactory;
6+
use SwooleTW\Http\Helpers\FW;
7+
use SwooleTW\Http\Task\QueueFactory;
8+
9+
$version = FW::version();
10+
$framework = ucfirst(FW::current());
11+
$color = "\033[0;32m";
12+
$noColor = "\033[0m";
13+
$stubs = [];
14+
15+
/* Copy queue class */
16+
$stub = QueueFactory::stub($version);
17+
QueueFactory::copy($stub, true);
18+
$stubs[] = $stub;
19+
20+
/* Copy connector class */
21+
$stub = ConnectorFactory::stub($version);
22+
ConnectorFactory::copy($stub, true);
23+
$stubs[] = $stub;
24+
25+
foreach ($stubs as $stub) {
26+
echo "{$color}{$framework}{$noColor}: {$color}{$version}{$noColor}. Successfully copied stub: {$color}{$stub}{$noColor}\n";
27+
}

phpunit.xml.dist

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
stopOnFailure="false"
1616
verbose="true"
1717
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer">
18-
<testsuites>
19-
<testsuite name="Laravel Swoole Http Test Suite">
20-
<directory suffix="Test.php">./tests</directory>
21-
</testsuite>
22-
</testsuites>
2318
<filter>
2419
<whitelist processUncoveredFilesFromWhitelist="true">
2520
<directory suffix=".php">./src</directory>
2621
</whitelist>
2722
</filter>
23+
<testsuites>
24+
<testsuite name="Laravel Swoole Http Test Suite">
25+
<directory suffix="Test.php">./tests</directory>
26+
</testsuite>
27+
</testsuites>
2828
<php>
2929
<const name="IN_PHPUNIT" value="true"/>
3030
</php>

routes/laravel_routes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
34
use Illuminate\Support\Facades\Route;
45

56
/*

0 commit comments

Comments
 (0)