skoro/slim-swoole-integration 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

skoro/slim-swoole-integration

Composer 安装命令:

composer require skoro/slim-swoole-integration

包简介

Integration of Slim framework and Swoole - event driven asynchronous library

README 文档

README

This package provides an integration of Slim Framework and event-based async Swoole library.

Install from composer:

composer require skoro/slim-swoole-integration

Example (server.php):

$server = new \Swoole\Http\Server('localhost', 9501);
$app = \Slim\Factory\AppFactory::create();

$app->get('/', function (\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response) {
    $response->getBody()->write('Hello');
    return $response;
});

$server->on('request', \Slim\Swoole\ServerRequestFactory::createRequestCallback($app));

$server->start();

After starting above server with php server.php command it will be listening on localhost and 9501 port.

Hot code reloading

Because Swoole works in a different way than PHP-FPM it doesn't reload the sources you changed between the requests as it PHP-FPM does. When you changed the sources you have to restart the server to apply your source changes and that can become annoying.

This library provides automatic server reloading depending on the file system changes, but it relies on PHP pecl inotify extension, and it should be installed first.

Please keep in mind, Swoole cannot handle included PHP files before WorkerStart event: https://www.swoole.co.uk/docs/modules/swoole-server-reload#checking-loaded-files.

Example:

// $server is created in the above example.
$server->on('start', function ($server) {
    $watcher = new \Slim\Swoole\FileWatchers\InotifyWatcher();
    $watcher->addFilePath('path to your project sources');

    // Reloader tracks the changes every 1000 ms.
    $reloader = new \Slim\Swoole\HotCodeReloader($watcher, $server, 1000);
    $reloader->start();
});

统计信息

  • 总下载量: 119
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固