Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: swooletw/laravel-swoole
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.10.0
Choose a base ref
...
head repository: swooletw/laravel-swoole
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Oct 24, 2021

  1. Clear auth instance on every requests

    Currenly auth instance is resseting after swoole reload/restart, and after user login - it shares auth across all other requests.
    
    This commit fixes:
    1) Logout user after swoole reload
    2) Share auth instance across all requests
    ad-mos authored Oct 24, 2021
    Copy the full SHA
    82687eb View commit details

Commits on Nov 4, 2021

  1. Added openswoole extension check compatibility

    Swoole now became `openswoole`, from version 4.7.2 swoole extension changed as openswoole. For this reason, this package can not detect the extension and shows the message *Can't detect Swoole extension installed.* This commit fixed the issue.
    nahid authored Nov 4, 2021
    Copy the full SHA
    b193a9a View commit details

Commits on Dec 2, 2021

  1. Merge pull request #506 from nahid/master

    Added openswoole extension check compatibility
    Arkanius authored Dec 2, 2021
    Copy the full SHA
    e00771a View commit details

Commits on Jan 20, 2022

  1. Merge pull request #507 from ad-mos/patch-1

    Clear auth instance on every requests
    Arkanius authored Jan 20, 2022
    Copy the full SHA
    43d0878 View commit details

Commits on Feb 17, 2022

  1. Copy the full SHA
    9b85684 View commit details
  2. Copy the full SHA
    2be1bc1 View commit details

Commits on Mar 19, 2022

  1. Merge pull request #518 from alecpl/dev/laravel-v9

    Support Laravel v9 + Github Actions
    Arkanius authored Mar 19, 2022
    Copy the full SHA
    4db6c7e View commit details
  2. rollback constructor

    Arkanius committed Mar 19, 2022
    Copy the full SHA
    3567be4 View commit details
  3. Merge pull request #521 from swooletw/hotfix/revert-pusher-message

    rollback constructor
    Arkanius authored Mar 19, 2022
    Copy the full SHA
    b9b766a View commit details

Commits on Mar 23, 2022

  1. Copy the full SHA
    1105f31 View commit details

Commits on Apr 1, 2022

  1. Merge pull request #522 from edricwilliem/master

    convert request to lumen request on lumen application
    Arkanius authored Apr 1, 2022
    Copy the full SHA
    711d7f6 View commit details

Commits on Apr 4, 2022

  1. Copy the full SHA
    7e60b15 View commit details

Commits on Mar 13, 2023

  1. Merge pull request #523 from amcsi/patch-1

    Fix deprecated null potentially being passed to strpos()
    Arkanius authored Mar 13, 2023
    Copy the full SHA
    8e01730 View commit details

Commits on Mar 28, 2023

  1. Copy the full SHA
    9ec3c9c View commit details

Commits on Apr 13, 2023

  1. Merge pull request #543 from larowka/master

    Support php 8.1 and laravel 10
    Arkanius authored Apr 13, 2023
    Copy the full SHA
    55ff29f View commit details

Commits on Apr 14, 2023

  1. ci: Fix ci tests

    kauanslr committed Apr 14, 2023
    Copy the full SHA
    23edcb6 View commit details
  2. Copy the full SHA
    ce9791a View commit details
  3. tests: mark test as skipped

    kauanslr committed Apr 14, 2023
    Copy the full SHA
    2f8aed4 View commit details
  4. Copy the full SHA
    9fe984b View commit details
  5. Copy the full SHA
    0a80156 View commit details
  6. Copy the full SHA
    ce89f58 View commit details
  7. Copy the full SHA
    402bf30 View commit details

Commits on Apr 19, 2023

  1. Copy the full SHA
    2ba76ff View commit details
  2. Copy the full SHA
    2d542cb View commit details
  3. Merge pull request #544 from kauanslr/ci-fix

    ci: fix ci tests
    Arkanius authored Apr 19, 2023
    Copy the full SHA
    250f1f3 View commit details

Commits on Sep 8, 2024

  1. Update README.md

    albertcht authored Sep 8, 2024
    Copy the full SHA
    ab2da11 View commit details

Commits on Sep 10, 2024

  1. Update README.md

    albertcht authored Sep 10, 2024
    Copy the full SHA
    27bfd2f View commit details
66 changes: 66 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: tests

on:
push:
pull_request:

jobs:
linux_tests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')"

strategy:
fail-fast: true
matrix:
include:
- php: "7.4"
framework: "laravel/framework:^8.0"
swoole: "4.4.17"
- php: "7.4"
framework: "laravel/framework:^8.0"
swoole: "4.8.13"
- php: "8.0"
framework: "laravel/framework:^8.0"
swoole: "4.5.9"
- php: "8.0"
framework: "laravel/framework:^8.0"
swoole: "4.8.13"
- php: "8.0"
framework: "laravel/framework:^9.0"
swoole: "4.5.9"
- php: "8.0"
framework: "laravel/framework:^9.0"
swoole: "4.8.13"
- php: "8.1"
framework: "laravel/framework:^10.0"
swoole: "4.8.3"
- php: "8.1"
framework: "laravel/framework:^10.0"
swoole: "4.8.13"
- php: "8.2"
framework: "laravel/framework:^10.0"
swoole: "4.8.12"
- php: "8.2"
framework: "laravel/framework:^10.0"
swoole: "4.8.13"

name: PHP ${{ matrix.php }} (${{ matrix.framework }}) swoole-(${{ matrix.swoole }})

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: swoole-${{ matrix.swoole }}
coverage: none

- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: |
composer require ${{ matrix.framework }} --no-update -n
COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o
- name: Execute tests
run: vendor/bin/phpunit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Files
.DS_Store
phpunit.xml
.phpunit.result.cache
composer.lock
.scannerwork

12 changes: 0 additions & 12 deletions .scrutinizer.yml

This file was deleted.

55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
> **Warning**
>
> This package is no longer maintained, we strongly recommend using Laravel's official [laravel/octane](https://github.com/laravel/octane) as an alternative.
>
> If you need coroutine support, consider trying [laravel-hyperf](https://github.com/swooletw/laravel-hyperf) for higher performance (This is a Laravel style Hyperf framework.)
# Laravel-Swoole

![php-badge](https://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg)
33 changes: 20 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -21,21 +21,23 @@
}
],
"require": {
"php": "^7.2|^8.0",
"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"
"php": ">=7.4|<=8.2",
"ext-swoole": "^4",
"illuminate/console": ">=5.4",
"illuminate/contracts": ">=5.4",
"illuminate/http": ">=5.4",
"illuminate/support": ">=5.4",
"predis/predis": "^1.1",
"laravel/framework":"v5.4"
},
"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",
"laravel/lumen-framework": ">=5.4",
"phpunit/phpunit": ">=8.5",
"phpunit/php-code-coverage": ">=7.0",
"php-coveralls/php-coveralls": ">=2.1",
"mockery/mockery": "^1.3",
"codedungeon/phpunit-result-printer": "^0.31.0",
"php-mock/php-mock": "^2.3",
"swoole/ide-helper": "@dev"
},
"autoload": {
@@ -69,5 +71,10 @@
"post-autoload-dump": [
"@php copy_versioned_files.php"
]
},
"config": {
"allow-plugins": {
"kylekatarnls/update-helper": true
}
}
}
4 changes: 2 additions & 2 deletions config/swoole_http.php
Original file line number Diff line number Diff line change
@@ -81,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', 'auth',
'encrypter', 'hash', 'router', 'translator', 'url', 'log',
],

/*
@@ -90,7 +90,7 @@
|--------------------------------------------------------------------------
*/
'instances' => [
//
'auth',
],

/*
2 changes: 1 addition & 1 deletion src/Commands/HttpServerCommand.php
Original file line number Diff line number Diff line change
@@ -370,7 +370,7 @@ protected function checkEnvironment()
exit(1);
}

if (! extension_loaded('swoole')) {
if (! extension_loaded('swoole') && ! extension_loaded('openswoole')) {
$this->error('Can\'t detect Swoole extension installed.');

exit(1);
5 changes: 5 additions & 0 deletions src/Server/Manager.php
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
use SwooleTW\Http\Concerns\InteractsWithSwooleQueue;
use SwooleTW\Http\Concerns\InteractsWithSwooleTable;
use Symfony\Component\ErrorHandler\Error\FatalError;
use Laravel\Lumen\Http\Request as LumenRequest;

/**
* Class Manager
@@ -215,6 +216,10 @@ public function onRequest($swooleRequest, $swooleResponse)
// transform swoole request to illuminate request
$illuminateRequest = Request::make($swooleRequest)->toIlluminate();

if (!$sandbox->isLaravel()) { // is lumen app
$illuminateRequest = LumenRequest::createFromBase($illuminateRequest);
}

// set current request to sandbox
$sandbox->setRequest($illuminateRequest);

2 changes: 1 addition & 1 deletion src/Transformers/Request.php
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ protected function createIlluminateRequest($get, $post, $cookie, $files, $server

$request = new SymfonyRequest($get, $post, [], $cookie, $files, $server, $content);

if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
if (0 === strpos($request->headers->get('CONTENT_TYPE', ''), 'application/x-www-form-urlencoded')
&& in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])
) {
parse_str($request->getContent(), $data);
4 changes: 2 additions & 2 deletions src/Websocket/Pusher.php
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ class Pusher
protected $event;

/**
* @var string|null
* @var mixed|null
*/
protected $message;

@@ -68,7 +68,7 @@ protected function __construct(
bool $broadcast,
bool $assigned,
string $event,
?string $message,
$message = null,
$server
)
{
2 changes: 1 addition & 1 deletion tests/Coroutine/ConnectorFactoryTest.php
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
*/
class ConnectorFactoryTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->mockEnv('Laravel\Lumen');
2 changes: 1 addition & 1 deletion tests/Coroutine/ContextTest.php
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ public function testGetDataKeyInCoroutine()
$coroutineId2 = null;
$coroutineId3 = null;

\Swoole\Coroutine\run(function () use (&$data1, &$data2, &$data3, &$coroutineId1, &$coroutineId2, &$coroutineId3) {
go(function () use (&$data1, &$data2, &$data3, &$coroutineId1, &$coroutineId2, &$coroutineId3) {
Context::setData('foo', 'bar');

$data1 = Context::getData('foo');
27 changes: 27 additions & 0 deletions tests/Server/ManagerTest.php
Original file line number Diff line number Diff line change
@@ -201,6 +201,18 @@ public function testOnRequest()

return $websocket;
});

app()->instance('config', new \Illuminate\Config\Repository([
'swoole_http' => [
'server' => [
'options' => [
'http_compression' => false,
]
],
],
]));


$container->singleton(Sandbox::class, function () {
$sandbox = m::mock(Sandbox::class);
$sandbox->shouldReceive('setRequest')
@@ -213,6 +225,9 @@ public function testOnRequest()
->once();
$sandbox->shouldReceive('disable')
->once();
$sandbox->shouldReceive('isLaravel')
->once()
->andReturnTrue();

return $sandbox;
});
@@ -271,6 +286,16 @@ public function testOnRequestException()
return $handler;
});

app()->instance('config', new \Illuminate\Config\Repository([
'swoole_http' => [
'server' => [
'options' => [
'http_compression' => false,
]
],
],
]));

$this->mockMethod('base_path', function () {
return '/';
});
@@ -342,6 +367,8 @@ public function testSetWebsocketHandler()

public function testLogServerError()
{
$this->markTestSkipped();

$exception = new \Exception;
$container = $this->getContainer();
$container->singleton(ExceptionHandler::class, function () use ($exception) {
2 changes: 1 addition & 1 deletion tests/Task/QueueFactoryTest.php
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
*/
class QueueFactoryTest extends TestCase
{
public function setUp()
public function setUp(): void
{
parent::setUp();
$this->mockEnv('Laravel\Lumen');
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -11,17 +11,17 @@

class TestCase extends BaseTestCase
{
public function tearDown()
public function tearDown(): void
{
$this->addToAssertionCount(
m::getContainer()->mockery_getExpectationCount()
);

Context::clear();
Mock::disableAll();
Facade::clearResolvedInstances();
parent::tearDown();
m::close();
Mock::disableAll();
}

protected function mockMethod($name, \Closure $function, $namespace = null)
Loading