- What is hyperf/server used for?
- Hyperf/Server provides the core coroutine server abstraction for the Hyperf framework. It handles server lifecycle management, configuration, and transport primitives used by HTTP, WebSocket, and TCP components. Most applications use it indirectly through higher-level Hyperf packages rather than requiring it directly.
- How do I install hyperf/server in a Laravel project?
- You generally should not install hyperf/server in a Laravel project because it is built for the Hyperf framework, not Laravel. Composer can install the package, but it will not integrate with Laravel's HTTP kernel, service container, or routing. Laravel developers usually choose Laravel Octane, RoadRunner, or a dedicated Swoole integration instead.
- Is hyperf/server compatible with Laravel?
- No, hyperf/server is not a Laravel package and does not provide Laravel service providers, facades, or middleware integration. It is part of Hyperf and expects the Hyperf application lifecycle and coroutine runtime. It is not a drop-in replacement for Laravel's HTTP server stack.
- Which PHP extensions does hyperf/server require?
- Hyperf/Server runs on the Hyperf coroutine runtime, which uses Swoole or Swow. You need the matching PHP extension, such as ext-swoole or ext-swow, plus a PHP version supported by your Hyperf release. It does not run under the standard PHP-FPM request model.
- How do I configure servers in hyperf/server?
- Configuration is handled through Hyperf config files, typically config/autoload/server.php in a Hyperf application. You define server names, types, hosts, ports, and runtime settings there, and Hyperf/Server uses that configuration to manage the server lifecycle. The exact options depend on whether you use Swoole or Swow.
- What is the difference between hyperf/server and hyperf/http-server?
- Hyperf/Server provides the low-level coroutine server abstraction, lifecycle management, and transport primitives. Hyperf/HTTP-Server builds HTTP protocol handling on top of that foundation and is what most web applications require. Similar protocol packages exist for WebSocket and TCP services.
- Can I use hyperf/server for WebSocket or TCP services?
- Yes, Hyperf/Server supplies transport primitives used by HTTP, WebSocket, and TCP components. You configure the relevant server type and pair it with the appropriate protocol package or callbacks. Direct use requires familiarity with Hyperf's server configuration and event lifecycle.
- How do I test a Hyperf server built on hyperf/server?
- Test application logic with Hyperf's testing utilities and coroutine-aware test setup where available. For integration coverage, start the server in a controlled test environment and make real client requests against it. Keep protocol-specific tests in the higher-level component packages such as HTTP or WebSocket.
- What are production concerns for hyperf/server?
- Production deployments need the Swoole or Swow extension, a process supervisor, appropriate worker settings, structured logging, and graceful reload handling. Run the server behind a reverse proxy or load balancer for TLS termination and traffic management. Monitor memory usage and coroutine behavior, and follow Hyperf's deployment guidance.
- What are alternatives to hyperf/server?
- Alternatives include Laravel Octane with Swoole or RoadRunner, standalone RoadRunner, ReactPHP, AMPHP, and native Swoole servers. Hyperf/Server is the best fit when you are already building on Hyperf and want its coroutine lifecycle and transport abstractions. It is maintained as part of the Hyperf ecosystem, so version compatibility should follow your Hyperf release.