承接 valkyrja/openswoole 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

valkyrja/openswoole

Composer 安装命令:

composer require valkyrja/openswoole

包简介

OpenSwoole persistent worker entry point for the Valkyrja Framework.

README 文档

README

Valkyrja OpenSwoole

OpenSwoole persistent worker entry point for the Valkyrja PHP framework.

This integration bootstraps the Valkyrja application once at worker startup, then dispatches every incoming request to an isolated child container so request state never bleeds between concurrent requests. The result is the performance benefit of a persistent process without the state-contamination risks of naive long-running PHP.

PHP Version Require Latest Stable Version License CI Status Scrutinizer Coverage Status Psalm Shepherd Maintainability Rating

Requirements

  • PHP 8.4+
  • The OpenSwoole PHP extension (openswoole/core ^26.2.0)
  • An existing Valkyrja application

Installation

composer require valkyrja/openswoole

Usage

Wire the OpenSwoole entry point into your application's front controller:

// app/public/index.php
use Valkyrja\Application\Data\HttpConfig;
use Valkyrja\OpenSwoole\OpenSwooleHttp;

OpenSwooleHttp::run(new HttpConfig(
    dir: __DIR__ . '/..',
));

run() bootstraps the application once when the worker process starts, then starts the OpenSwoole HTTP server. Each request is handled in an isolated child container so state never bleeds between requests.

Customizing the Server

Override getSwooleServer() to configure the server address, port, or options:

use OpenSwoole\HTTP\Server;
use Valkyrja\OpenSwoole\OpenSwooleHttp;

class App extends OpenSwooleHttp
{
    public static function getSwooleServer(): Server
    {
        $server = new Server('0.0.0.0', 8080);
        $server->set([
            'worker_num'  => 4,
            'max_request' => 10000,
        ]);

        return $server;
    }
}

Customizing Bootstrap

Override bootstrapParentServices() to force-resolve services that are expensive to create and safe to share across requests:

use Valkyrja\Application\Kernel\Contract\ApplicationContract;
use Valkyrja\Http\Routing\Collection\Contract\CollectionContract;
use Valkyrja\OpenSwoole\OpenSwooleHttp;

class App extends OpenSwooleHttp
{
    protected static function bootstrapParentServices(ApplicationContract $app): void
    {
        $container = $app->getContainer();
        $container->getSingleton(CollectionContract::class);
        $container->getSingleton(MyExpensiveSharedService::class);
    }
}

Worker Lifecycle

See the Valkyrja framework repository for a full explanation of the persistent worker lifecycle, the child container isolation model, and configuration options.

Related Integrations

Other persistent-worker runtime integrations for Valkyrja PHP:

  • FrankenPHP — persistent worker via the FrankenPHP embedded runtime
  • RoadRunner — persistent worker via the Go-based RoadRunner manager

Contributing

See CONTRIBUTING.md for the submission process and VOCABULARY.md for the terminology used across Valkyrja.

Security Issues

If you discover a security vulnerability, please follow our disclosure procedure.

License

Licensed under the MIT license. See LICENSE.md.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固