Skip to content

Commit

Permalink
Merge pull request #2 from swooletw/master
Browse files Browse the repository at this point in the history
resync
  • Loading branch information
hezachary authored Dec 4, 2020
2 parents cbb9914 + 714cb6d commit 0bd0037
Show file tree
Hide file tree
Showing 131 changed files with 6,003 additions and 1,564 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store
phpunit.xml
composer.lock
.scannerwork

# Folders
vendor
Expand Down
12 changes: 12 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
build:
environment:
php: 7.2

filter:
excluded_paths:
- "tests/*"
- "routes/*"
- "config/*"
- "stubs/*"
dependency_paths:
- "vendor/*"
24 changes: 11 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,24 @@ sudo: false

matrix:
include:
- php: 7.2
env: FRAMEWORK_VERSION=laravel/framework:5.1.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/framework:5.2.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/framework:5.3.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/framework:5.4.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/framework:5.5.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.1.*
env: FRAMEWORK_VERSION=laravel/framework:5.6.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.2.*
env: FRAMEWORK_VERSION=laravel/framework:5.7.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.3.*
env: FRAMEWORK_VERSION=laravel/framework:5.8.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.4.*
env: FRAMEWORK_VERSION=laravel/framework:6.0.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.5.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.6.*
- php: 7.2
env: FRAMEWORK_VERSION=laravel/lumen-framework:5.7.*
# - php: 7.2
# env: FRAMEWORK_VERSION=laravel/lumen-framework:5.8.*

before_install:
- printf "\n" | pecl install swoole
Expand All @@ -37,4 +35,4 @@ script:
- vendor/bin/phpunit --coverage-clover build/logs/clover.xml

after_success:
- vendor/bin/coveralls -v
- vendor/bin/php-coveralls -v
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Laravel-Swoole

![php-badge](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg)
![php-badge](https://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg)
[![packagist-badge](https://img.shields.io/packagist/v/swooletw/laravel-swoole.svg)](https://packagist.org/packages/swooletw/laravel-swoole)
[![Total Downloads](https://poser.pugx.org/swooletw/laravel-swoole/downloads)](https://packagist.org/packages/swooletw/laravel-swoole)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/swooletw/laravel-swoole/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/swooletw/laravel-swoole/?branch=master)
Expand All @@ -12,7 +12,7 @@ This package provides a high performance HTTP server to speed up your Laravel/Lu

| PHP | Laravel | Lumen | Swoole |
|:-------:|:-------:|:-----:|:-------:|
| >=7.1 | ~5.1 | ~5.1 | >=4.0.0 |
| >=7.2 | >=5.5 | >=5.5 | >=4.3.1 |

## Features

Expand Down
125 changes: 69 additions & 56 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,73 @@
{
"name": "swooletw/laravel-swoole",
"description": "High performance HTTP server based on Swoole. Speed up your Laravel and Lumen applications.",
"keywords": ["swoole", "laravel", "lumen", "performance", "http", "server"],
"license": "MIT",
"authors": [
{
"name": "Albert Chen",
"email": "albert@unisharp.com"
},
{
"name": "Huang Yi",
"email": "coodeer@163.com"
}
],
"require": {
"php": "^7.1",
"illuminate/console": "~5.1",
"illuminate/contracts": "~5.1",
"illuminate/http": "~5.1",
"illuminate/support": "~5.1",
"predis/predis": "^1.1"
},
"require-dev": {
"laravel/lumen-framework": "~5.1",
"phpunit/phpunit": "^6.1",
"phpunit/php-code-coverage": "^5.2",
"satooshi/php-coveralls": "^1.0",
"mockery/mockery": "~1.0",
"codedungeon/phpunit-result-printer": "^0.14.0",
"php-mock/php-mock": "^2.0"
},
"autoload": {
"files": [
"src/Server/helpers.php"
],
"psr-4": {
"SwooleTW\\Http\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"SwooleTW\\Http\\Tests\\": "tests",
"SwooleTW\\Http\\Tests\\Fixtures\\Laravel\\App\\": "tests/fixtures/laravel/app"
}
"name": "swooletw/laravel-swoole",
"description": "High performance HTTP server based on Swoole. Speed up your Laravel and Lumen applications.",
"keywords": [
"swoole",
"laravel",
"lumen",
"performance",
"http",
"server"
],
"license": "MIT",
"authors": [
{
"name": "Albert Chen",
"email": "albert@unisharp.com"
},
"extra": {
"laravel": {
"providers": [
"SwooleTW\\Http\\LaravelServiceProvider"
],
"aliases": {
"Server": "SwooleTW\\Http\\Server\\Facades\\Server",
"Table": "SwooleTW\\Http\\Server\\Facades\\Table",
"Room": "SwooleTW\\Http\\Websocket\\Facades\\Room",
"Websocket": "SwooleTW\\Http\\Websocket\\Facades\\Websocket"
}
}
{
"name": "Huang Yi",
"email": "coodeer@163.com"
}
],
"require": {
"php": "^7.2",
"illuminate/console": "~5.4|~6.0|~7.0|~8.0",
"illuminate/contracts": "~5.4|~6.0|~7.0|~8.0",
"illuminate/http": "~5.4|~6.0|~7.0|~8.0",
"illuminate/support": "~5.4|~6.0|~7.0|~8.0",
"predis/predis": "^1.1"
},
"require-dev": {
"laravel/lumen-framework": "~5.4|~6.0|~7.0|~8.0",
"phpunit/phpunit": "^7.5",
"phpunit/php-code-coverage": "^6.1",
"php-coveralls/php-coveralls": "^2.1",
"mockery/mockery": "~1.0",
"codedungeon/phpunit-result-printer": "^0.14.0",
"php-mock/php-mock": "^2.0",
"swoole/ide-helper": "@dev"
},
"autoload": {
"files": [
"src/Server/helpers.php"
],
"psr-4": {
"SwooleTW\\Http\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"SwooleTW\\Http\\Tests\\": "tests",
"SwooleTW\\Http\\Tests\\Fixtures\\Laravel\\App\\": "tests/fixtures/laravel/app"
}
},
"extra": {
"laravel": {
"providers": [
"SwooleTW\\Http\\LaravelServiceProvider"
],
"aliases": {
"Server": "SwooleTW\\Http\\Server\\Facades\\Server",
"Table": "SwooleTW\\Http\\Server\\Facades\\Table",
"Room": "SwooleTW\\Http\\Websocket\\Facades\\Room",
"Websocket": "SwooleTW\\Http\\Websocket\\Facades\\Websocket"
}
}
},
"scripts": {
"post-autoload-dump": [
"@php copy_versioned_files.php"
]
}
}
21 changes: 17 additions & 4 deletions config/swoole_http.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

use Swoole\Table;

return [
/*
|--------------------------------------------------------------------------
Expand All @@ -17,9 +15,11 @@
'public_path' => base_path('public'),
// Determine if to use swoole to respond request for static files
'handle_static_files' => env('SWOOLE_HANDLE_STATIC', true),
'access_log' => env('SWOOLE_HTTP_ACCESS_LOG', false),
// You must add --enable-openssl while compiling Swoole
// Put `SWOOLE_SOCK_TCP | SWOOLE_SSL` if you want to enable SSL
'socket_type' => SWOOLE_SOCK_TCP,
'process_type' => SWOOLE_PROCESS,
'options' => [
'pid_file' => env('SWOOLE_HTTP_PID_FILE', base_path('storage/logs/swoole_http.pid')),
'log_file' => env('SWOOLE_HTTP_LOG_FILE', base_path('storage/logs/swoole_http.log')),
Expand Down Expand Up @@ -53,6 +53,19 @@
'enabled' => env('SWOOLE_HTTP_WEBSOCKET', false),
],

/*
|--------------------------------------------------------------------------
| Hot reload configuration
|--------------------------------------------------------------------------
*/
'hot_reload' => [
'enabled' => env('SWOOLE_HOT_RELOAD_ENABLE', false),
'recursively' => env('SWOOLE_HOT_RELOAD_RECURSIVELY', true),
'directory' => env('SWOOLE_HOT_RELOAD_DIRECTORY', base_path()),
'log' => env('SWOOLE_HOT_RELOAD_LOG', true),
'filter' => env('SWOOLE_HOT_RELOAD_FILTER', '.php'),
],

/*
|--------------------------------------------------------------------------
| Console output will be transferred to response content if enabled.
Expand All @@ -68,7 +81,7 @@
'pre_resolved' => [
'view', 'files', 'session', 'session.store', 'routes',
'db', 'db.factory', 'cache', 'cache.store', 'config', 'cookie',
'encrypter', 'hash', 'router', 'translator', 'url', 'log',
'encrypter', 'hash', 'router', 'translator', 'url', 'log', 'auth',
],

/*
Expand Down Expand Up @@ -120,5 +133,5 @@
// ['name' => 'column_name', 'type' => Table::TYPE_STRING, 'size' => 1024],
// ]
// ],
]
],
];
14 changes: 12 additions & 2 deletions config/swoole_websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
// SwooleTW\Http\Websocket\Middleware\Authenticate::class,
],

/*
|--------------------------------------------------------------------------
| Websocket handler for customized onHandShake callback
|--------------------------------------------------------------------------
*/
'handshake' => [
'enabled' => false,
'handler' => SwooleTW\Http\Websocket\HandShakeHandler::class,
],

/*
|--------------------------------------------------------------------------
| Default websocket driver
Expand Down Expand Up @@ -77,7 +87,7 @@
'room_rows' => 4096,
'room_size' => 2048,
'client_rows' => 8192,
'client_size' => 2048
'client_size' => 2048,
],

'redis' => [
Expand All @@ -92,6 +102,6 @@
//
],
'prefix' => 'swoole:',
]
],
],
];
33 changes: 33 additions & 0 deletions copy_versioned_files.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

require __DIR__.'/vendor/autoload.php';

use SwooleTW\Http\Helpers\FW;
use SwooleTW\Http\Task\QueueFactory;
use SwooleTW\Http\Coroutine\Connectors\ConnectorFactory;

try {
$framework = ucfirst(FW::current());
$version = FW::version();
} catch (Throwable $e) {
echo "No files were generated.\n";
die;
}

$color = "\033[0;32m";
$noColor = "\033[0m";
$stubs = [];

/* Copy queue class */
$stub = QueueFactory::stub($version);
QueueFactory::copy($stub, true);
$stubs[] = $stub;

/* Copy connector class */
$stub = ConnectorFactory::stub($version);
ConnectorFactory::copy($stub, true);
$stubs[] = $stub;

foreach ($stubs as $stub) {
echo "{$color}{$framework}{$noColor}: {$color}{$version}{$noColor}. Successfully copied stub: {$color}{$stub}{$noColor}\n";
}
10 changes: 5 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
stopOnFailure="false"
verbose="true"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer">
<testsuites>
<testsuite name="Laravel Swoole Http Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="Laravel Swoole Http Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<php>
<const name="IN_PHPUNIT" value="true"/>
</php>
Expand Down
1 change: 1 addition & 0 deletions routes/laravel_routes.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php


use Illuminate\Support\Facades\Route;

/*
Expand Down
9 changes: 2 additions & 7 deletions routes/lumen_routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,5 @@
|
*/

$app->get('socket.io', [
'as' => 'io.get', 'uses' => 'SocketIOController@upgrade'
]);

$app->post('socket.io', [
'as' => 'io.post', 'uses' => 'SocketIOController@reject'
]);
$router->get('socket.io', ['uses' => 'SocketIOController@upgrade']);
$router->post('socket.io', ['uses' => 'SocketIOController@reject']);
3 changes: 1 addition & 2 deletions routes/websocket.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php


use Illuminate\Http\Request;
use SwooleTW\Http\Websocket\Facades\Websocket;

Expand All @@ -23,5 +24,3 @@
Websocket::on('example', function ($websocket, $data) {
$websocket->emit('message', $data);
});

// Websocket::on('test', 'ExampleController@method');
Loading

0 comments on commit 0bd0037

Please sign in to comment.