amphp/thread
Thread-local storage for Amp applications. Store and retrieve values scoped to the current fiber or thread, keeping state isolated across concurrent tasks and preventing leaks between async operations. A small utility for safer context handling in Amp-based PHP apps.
Start by not starting. amphp/thread is archived, has had no release since 2014-09-09, and its own description points you at amphp/parallel. There is no day-to-day leverage to gain here in a modern Laravel codebase — the realistic first use case is removing it, not adopting it.
Before you write any code, establish why the package is in the tree at all:
composer why amphp/thread — find the transitive dependency or the forgotten require.composer show amphp/thread — confirm you are on the 2014 line.grep -R "Amp\\\\Thread\|amphp/thread" app/ config/ routes/ — find actual call sites vs. dead weight.php -v, php -m | grep -i pthreads, and whether your PHP is ZTS (php -i | grep Thread). This package rode on ext-pthreads, which requires a ZTS build. Official php Docker images, Laravel Sail, Herd, and Valet are almost all NTS. If pthreads is not loaded, the package cannot work at all.If you genuinely must run legacy code that depends on it (e.g. an old CLI worker script), isolate it in a dedicated container pinned to the matching PHP version, run it only from artisan/CLI, and never load it in the HTTP or queue worker process.
The correct first "use case" to learn instead is amphp/parallel (v2, fiber-based) for in-process-style parallelism via worker processes, or plain Laravel queues for anything that can tolerate latency. For CPU-bound fan-out, Illuminate\Process / Symfony\Process is usually the pragmatic choice.
Treat this package as a migration source, not an integration target. The patterns below are what you actually ship.
Adapter-first extraction. Wrap every call site behind a small interface (HeavyTaskRunner::run(callable $job, array $args)) so the legacy thread implementation and the replacement are swappable. The old API is built around spawning a worker that executes a serializable payload and returns a serializable result — mirror that contract exactly so the swap is mechanical.
Replace with amphp/parallel worker pools. For parallel CPU work:
Task implementing Amp\Parallel\Worker\Task.Worker\ContextWorkerPool / Worker\WorkerPool.artisan command (Amp\Loop::run(...) / Amp\async on Amp v3), never from a controller inside FPM.Replace with Laravel queues when possible. Most jobs people reached for threads to solve are better as dispatch() on a Horizon/Redis queue: retries, backoff, observability, and no ZTS build. Reserve true parallelism for sub-second fan-out where queue latency is unacceptable.
Replace with subprocesses for isolation. Process::run([...]) (or Symfony\Process) gives you crash isolation that pthreads never did. Good for image/PDF tooling, external binaries, and anything that might segfault.
Batch fan-out pattern. A common real-world shape: fetch N remote resources or run N CPU jobs, collect results, write once. With amphp/parallel, submit all tasks to the pool, Future\awaitAll, then persist in the parent process. With Laravel, Bus::batch([...])->dispatch() and use then() for the writeback. Both keep DB connections out of workers.
Integration tip: if you run Octane or a long-lived queue worker, do not spawn workers per request/loop iteration without a bounded pool — you will exhaust memory and file descriptors. Use a pool with a fixed size tied to nproc.
ext-pthreads requires a ZTS PHP build. Standard distro packages and Docker images are NTS; recompiling PHP just to run an archived 2014 library is almost never the right trade.pthreads is abandoned and does not support modern PHP (8.x). If your app is on PHP 8, this package is dead on arrival regardless of what composer.json says.amphp/amp v2/v3 and amphp/parallel if both are present. Expect composer update failures the moment you add a modern Async dependency.php.ini quirks. Per-thread memory limits and stack sizes are configured separately; a job that passes in CLI can OOM in a thread. Check memory_limit in the worker context, not just the parent.vendor/ overrides.amphp/parallel, a queued job, or Process. (3) Delete the require. (4) Remove any ZTS/pthreads build steps from Dockerfiles and CI. (5) Add a composer audit/composer outdated gate so abandoned packages don't creep back in.How can I help you explore Laravel packages today?