Download the PHP package phpdot/server-swoole without Composer

On this page you can find all versions of the php package phpdot/server-swoole. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package server-swoole

phpdot/server-swoole

Swoole HTTP/WebSocket server adapter for PSR-15. Framework-agnostic, standalone, full Swoole coverage.

Install

Requires ext-swoole >= 6.0 and PHP 8.3+.

Quick Start

$handler is any PSR-15 RequestHandlerInterface -- your router, your framework, your middleware pipeline.


Server Configuration

ServerConfig is a simple readonly data class. No static methods, no builders -- just named constructor parameters:

Workers & Process

SSL / HTTPS

Static Files

Static file requests bypass PHP entirely -- served directly by Swoole's kernel.

Compression

Raw Swoole Settings

For any Swoole setting not covered by typed properties:

Typed properties always take precedence over rawSettings.

Inside the phpdot framework

ServerConfig carries #[Config('server')], so when used with phpdot/package it's auto-hydrated from config/server.php:

The container resolves ServerConfig automatically — no manual new ServerConfig(...) needed when running inside the framework. Standalone consumers (no phpdot/package) instantiate ServerConfig directly via the constructor as shown above.

SwooleServer itself isn't auto-wired (its constructor uses an intersection type for the PSR-17 factory, which PHP-DI can't autowire). Register it manually in your application boot:

For per-coroutine scoping of Scope::SCOPED services (the standard pattern under Swoole), install phpdot/container-swoole and register its provider:


Event Callbacks

Register callbacks directly on the server. Multiple callbacks per event -- they stack, never replace:

Available Events

Category Events
Lifecycle onStart, onManagerStart, onManagerStop, onWorkerStart, onWorkerStop, onWorkerExit, onWorkerError, onBeforeShutdown, onShutdown, onBeforeReload, onAfterReload
Connection onConnect, onClose
Task onTask, onFinish
IPC onPipeMessage
WebSocket onOpen, onMessage, onHandshake, onDisconnect

WebSocket

When any WebSocket callback is registered, the server automatically creates a WebSocket\Server instead of Http\Server. HTTP and WebSocket work on the same port:

Active WebSocket Methods

Push messages and manage connections from anywhere in your application:


Task Workers

Offload heavy work to task worker processes:


Timers

Set recurring or one-shot timers:


Connection Management


Server Info & Lifecycle


Escape Hatch

For advanced Swoole features not directly exposed (addProcess, addListener, bind, protect, etc.):


Streaming (CallbackStreamInterface)

For real-time streaming (SSE, chunked responses), implement CallbackStreamInterface:

The ResponseConverter detects this interface and streams each chunk directly via $swooleResponse->write() -- data reaches the client immediately without buffering.


Architecture

Response Emission Strategies

The ResponseConverter selects the optimal strategy for each response:

Strategy When How
CallbackStream Body implements CallbackStreamInterface write() per chunk -- true streaming
Sendfile Body is a plain file stream sendfile() -- zero-copy kernel transfer
Empty Body size is 0 end() -- no body
Chunked Body exceeds chunk threshold (default 1 MB) write() in chunks
Direct Everything else end($body) -- single write

Production Example


Package Structure

PSR Standards

PSR Usage
PSR-7 ServerRequestInterface, ResponseInterface -- the bridge format
PSR-15 RequestHandlerInterface -- your application entry point
PSR-17 All 4 factories -- builds PSR-7 objects from Swoole data

Development

License

MIT


All versions of server-swoole with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-swoole Version >=6.0
psr/http-message Version ^2.0
psr/http-factory Version ^1.0
phpdot/contracts Version ^1.8
psr/http-server-handler Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package phpdot/server-swoole contains the following files

Loading the files please wait ...