- What is Pokio and what is it used for?
- Pokio is a dead-simple asynchronous API for PHP that provides async() and await() global functions. It uses PCNTL to fork processes and FFI shared memory for fast inter-process communication, letting you run independent I/O-bound tasks concurrently in CLI contexts. It is not a Laravel package with a service provider, config file, or facade; it is a low-level PHP utility you call from short-lived CLI scripts. It is intended for internal tooling and CI, not HTTP request handling or long-lived workers.
- How do I install nunomaduro/pokio in a Laravel project?
- Install it with Composer using composer require nunomaduro/pokio. It requires PHP 8.3+ and the PCNTL extension, while FFI should be enabled for actual shared-memory concurrency. There is no Laravel service provider, config file, or facade to publish. You call the global async() and await() functions from a CLI entry point or Artisan command.
- Does Pokio work with Laravel HTTP requests, Octane, or queue workers?
- No. Pokio is designed for short-lived CLI processes that fan out independent I/O-bound work and then exit. Forking inside HTTP requests, Octane workers, queue workers, or daemons clones the worker's heap, including open PDO connections, Redis sockets, locks, Guzzle clients, and log handlers, into child processes. That creates a fork-safety bug class because children may write to shared resources they no longer exclusively own. Use Laravel's Http::pool() or Concurrency primitives for request or worker concurrency instead.
- What happens if PCNTL or FFI is not available?
- Pokio is designed to degrade gracefully: without PCNTL, such as on Windows or some restricted hosts, or without FFI enabled by policy or hardened container images, it falls back to sequential execution rather than throwing. The code remains correct but loses parallel speed. That turns an environment-compatibility issue into a performance-variance issue. You should still test the fallback behavior in each environment where the script must run.
- Does Pokio support Laravel 10, 11, or 12?
- Pokio has no framework integration layer, so Laravel version support is not the primary constraint; the real requirements are PHP 8.3+ plus PCNTL and FFI availability. You can call async() and await() from an Artisan command or standalone CLI script in any Laravel version that runs on PHP 8.3+. There is no service provider or config to be compatible or incompatible. Validate against your application's PHP runtime and deployment images rather than a Laravel version matrix.
- Is Pokio safe to use in production?
- The README explicitly warns that Pokio manipulates process lifecycles with low-level and potentially unsafe techniques and says not to use it in production or to use it at your own risk. Treat production adoption as a deliberate, documented decision with a named owner, not a passive default. The bigger risks are fork safety of dependencies, unbounded process fan-out, and platform divergence between Linux, macOS, and Windows. Many teams should restrict Pokio to developer tooling and CI.
- How do I test code that uses async() and await()?
- Keep the forked unit of work small, independent, and free of shared mutable state so it can be tested sequentially. Run tests in an environment with PCNTL and FFI to exercise real concurrency, and also run without them to verify the sequential fallback path. Avoid assertions that depend on precise timing; assert results and side effects instead. Note that Xdebug debug mode disables forking in v1.0.1, so debugging produces sequential behavior.
- What are alternatives to Pokio for running PHP tasks concurrently?
- Check Laravel's Http::pool() for concurrent HTTP calls and the Concurrency primitive for supported Laravel workloads before reaching for process forking. For general PHP CLI parallelism, consider process pools or queue workers with proper isolation rather than unbounded async() calls. Pokio's niche is a dead-simple async()/await() API for short-lived CLI fan-out with graceful fallback. Alternatives should be chosen based on whether the workload is I/O-bound, how much isolation it needs, and whether the environment has PCNTL and FFI.
- Does Pokio have a concurrency limit or process pool?
- No. Pokio provides no pool, concurrency limit, or backpressure; one async() call corresponds to one OS process. A naive loop over 500 records can spawn 500 processes, and copy-on-write memory means a large bootstrapped Laravel container amplifies cost per child. You must batch work, limit fan-out in your own code, and avoid forking large heaps. If you need managed concurrency, use a pool or queue-based design instead.
- Who maintains Pokio and what is the release status?
- Pokio is maintained by Nuno Maduro, with an actively released 1.x line and an MIT license. It is a single-maintainer project, so the bus factor is mitigated by the maintainer's standing and active releases but not eliminated. Because it is MIT-licensed, the fallback is to vendor or fork the code rather than lose it entirely. Teams adopting it should assign ownership for version watching and the fallback path.