amphp/socket
Async, non-blocking socket library for AMPHP. Provides client/server abstractions over TCP, UDP, and Unix domain sockets with DNS resolution, retries, connect timeouts, cancellation, and optional TLS encryption. Implements ReadableStream/WritableStream.
connectTls/setupTls) simplifies secure communications, reducing dependency on ext-openssl for custom implementations.Amp\run()).Amp\async).amphp/pdo, amphp/redis).amphp/byte-stream (for ReadableStream/WritableStream).league/uri (for URI parsing in examples), ext-sockets (required for socket operations).ConnectException) differ from Laravel’s Illuminate\Support\Exceptions. Custom error mapping may be needed.opcache.enable_fibers=1)?php artisan queue:work) won’t work without fiber support.swoole/swoole for async sockets.reactphp/socket (if ReactPHP is already used).SocketService).run() to test socket operations without touching Laravel’s core.Amp\run(function () {
$socket = Amp\Socket\connect('example.com:80');
$socket->write("GET / HTTP/1.1\r\nHost: example.com\r\n\r\n");
$response = Amp\ByteStream\buffer($socket);
echo $response;
});
amphp/socket for performance-critical paths.Illuminate\Contracts\Http\Kernel to route async requests to Amp handlers.Route::get('/async-endpoint', function () {
return Amp\async(function () {
$socket = Amp\Socket\connect('db:3306');
// ... async DB logic
});
});
AppServiceProvider).Amp\async).ext-openssl (no need for ext-sodium).Socks5SocketConnector.amphp/http-client, this is a low-level socket library (HTTP/1.1 only).amphp/socket for background jobs or CLI scripts (lowest risk).amphp/socket in non-critical routes.amphp/socket + amphp/websocket.DnsSocketConnector).amphp/byte-stream, amphp/dns, etc., adding to Composer complexity.amphp/socket. May need custom support.spatie/async or laravel-amp (if available) for Laravel-specific helpers.file_get_contents) will block the fiber.wrk or k6) before production.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Fiber deadlock | App hangs indefinitely | Use `Amp\DeferredCanc |
How can I help you explore Laravel packages today?