yakeing/php_fsockopen
yakeing/php_fsockopen is a lightweight PHP wrapper around fsockopen for low-level socket and HTTP connections. It provides a simple way to open sockets, send requests, and read responses without cURL, making it useful for small integrations or environments where cURL isn't available.
Feature-level: unblocking network integrations without an engineering epic. This package is a thin, opinionated wrapper around PHP's native fsockopen/socket primitives, adding uniform support for tcp://, udp://, unix://, and udg:// endpoints. That maps directly onto a recurring class of roadmap items that are small in user-visible scope but disproportionate in engineering friction:
unix:// support is particularly relevant for probing local daemons (PHP-FPM status sockets, Redis/MySQL over unix sockets, container runtime sockets) that HTTP clients cannot reach.unix:///udg:// for inter-process messaging on a single host, useful in single-node deployments and CLI tooling before you invest in a message broker.Build vs. buy (really: adopt vs. write in-house). The honest framing is that this is not a buy decision. It is roughly a few hundred lines of code wrapping functions PHP already ships. The real choice is between: (a) taking the dependency, (b) copying the pattern into an internal helper class, or (c) adopting a proper async networking stack. For a Laravel codebase, a small internal SocketClient service — testable, mockable, PSR-compatible, and under your own maintenance — is usually the highest-value outcome, with this package as a reference implementation.
Roadmap signal. The existence of this gap tells you something useful: your team has recurring low-level networking needs that the framework does not cover. If more than two or three of the use cases above appear on the roadmap, that is a signal to standardise on a maintained abstraction (ReactPHP's socket component, Amp, or Symfony's HttpClient/Mime where applicable) rather than accumulating one-off fsockopen calls — which become a genuine reliability and testability liability at scale.
Explicitly not supported: async/concurrent I/O, connection pooling, automatic reconnection/backoff, TLS certificate management, HTTP semantics, or protocol framing. If a feature requires any of those, this package is the wrong foundation and the decision should be scoped upward.
Consider it when all of the following hold:
unix:// / udg:// support, which is the package's most differentiated convenience and the thing most HTTP abstractions cannot do.Look elsewhere when:
react/socket), Amp v3, or Swoole/OpenSwoole. These are actively maintained and purpose-built.curl, openssl, or a modern HTTP client rather than hand-rolled fsockopen with ssl://.symfony/http-client. Do not build HTTP on raw sockets.Decision rule of thumb: use it as reading material or a spike, and write or adopt a maintained abstraction for anything that ships. If it does ship, vendor it into your own namespace, pin it explicitly, add a compatibility test, and note it on a technical-debt register with a named owner and a review date.
For executives — 30 seconds. This is a small, free utility that lets us talk to internal services and probes over raw network connections without an engineering project. It is not a platform decision. The catch is that it is no longer maintained — last release 2019 — so my recommendation is to use it as a reference for a small in-house helper we own, not as a long-term dependency. Cost to replace: roughly one to two engineering days. Risk of adopting it directly: low today, rising with every PHP upgrade and every quarter it goes unpatched.
For engineering leadership. A thin fsockopen wrapper covering TCP, UDP, and Unix-domain sockets. Genuine value is the uniform interface and unix:// support; everything underneath is native PHP. It buys us roughly a day on a prototype and costs us a dependency we cannot patch. Recommended posture: mine it, don't marry it — copy the pattern into a PSR-compatible, DI-injectable internal client with timeouts, allowlisting, and a mocked transport for tests. If we find three or more such integrations on the roadmap, that is our cue to standardise on ReactPHP or Amp instead of growing a pile of blocking socket calls.
For the product/feature team. It unblocks things like service health checks, UDP metrics emission, syslog shipping, and talking to local daemons over Unix sockets — capabilities our HTTP tooling does not cover. It does not give us async, retries, connection pooling, or TLS handling; any feature needing those should be scoped as a separate, larger piece of work rather than assumed to be cheap.
For legal/compliance. MPL-2.0 — file-level copyleft, permissive enough for proprietary use as an unmodified dependency; obligations attach only if we modify and redistribute the package's own files. Flag the archived status and the 2019 vintage in the dependency register, and prefer an internal reimplementation if the licence question is at all distracting.
The one-line ask. Approve a timeboxed spike (1–2 days) to validate the pattern against our real protocol needs; default outcome is an internal helper we maintain, with this package credited as the reference and not shipped as a runtime dependency.
How can I help you explore Laravel packages today?