- Is react/http compatible with Laravel?
- No, react/http is not a Laravel package and is not compatible with standard Laravel applications out of the box. ReactPHP's event-driven, non-blocking model conflicts with Laravel's synchronous request lifecycle, and core features like Eloquent, sessions, and middleware assume blocking execution. It is best suited to isolated microservices or specialized high-concurrency endpoints rather than a typical Laravel app.
- How do I install react/http with Composer?
- Install it with composer require react/http. The README notes that the default branch contains the upcoming v3 development release, while the stable v1 release lives on the 1.x branch. Choose the version constraint that matches your production needs and review the installation instructions in the repository.
- Can I use react/http instead of Laravel's HTTP client or Guzzle?
- Not as a direct replacement. Laravel's HTTP client is synchronous and integrates with the framework's testing and mocking helpers, while react/http returns promises and streams responses asynchronously. You can use react/http for concurrent outbound requests in a ReactPHP event loop, but doing so inside a normal Laravel request would require blocking the loop and loses Laravel's built-in HTTP client conveniences.
- How do I send many concurrent async HTTP requests with react/http?
- The client component lets you send any number of async HTTP/HTTPS requests concurrently by returning promises from each request. You attach then handlers or use Promise utilities to aggregate results without blocking the event loop. This concurrency model is the main reason to choose react/http over a synchronous client.
- How does react/http handle redirects, timeouts, and authentication?
- The client supports configurable redirect following, request timeouts, and authentication options such as basic auth as documented in the README. These features are configured per request or via client options. Because everything is promise-based, timeouts and failures surface as rejected promises rather than exceptions thrown at call time.
- Can I run a ReactPHP HTTP server alongside a Laravel application?
- Running react/http's server alongside Laravel typically means replacing Nginx or PHP-FPM with a ReactPHP event loop, which breaks core Laravel functionality such as session handling and synchronous database access. The technical assessment rates integration feasibility as low for standard Laravel apps. It may be feasible for greenfield microservices where Laravel is not used, or for non-HTTP tasks like WebSocket servers.
- What PHP and Laravel versions does react/http support?
- react/http is a standalone ReactPHP package and does not declare Laravel version support. Its compatibility is with PHP versions required by ReactPHP and the react/socket and react/event-loop components. Check the package's composer.json and README for the current PHP requirement, and do not assume Laravel integration support.
- How do I test react/http code in a Laravel test suite?
- Testing async ReactPHP code requires running the event loop and resolving promises, which does not fit Laravel's standard HTTP test helpers. You would need to write tests that drive the loop and assert on promise resolution or streamed output. The technical assessment also flags debugging async flow as a challenge compared with Laravel's synchronous paradigm.
- Is react/http production-ready for high-concurrency services?
- react/http is the HTTP component of ReactPHP and provides async streaming client and server implementations, but the provided technical assessment rates technical risk as high for Laravel contexts. It notes minimal Packagist dependents and unproven stability in production, along with risks like event loop blocking from synchronous dependencies. Evaluate it carefully for isolated services where its async model is a natural fit.
- What are alternatives to react/http for async HTTP in Laravel?
- For standard Laravel apps, the built-in HTTP client or Guzzle with Laravel's concurrency helpers is usually the pragmatic choice. If you need a fully async stack, ReactPHP with react/http, Amp's HTTP client, or Swoole-based runtimes are common alternatives. Each requires evaluating how much of Laravel's synchronous ecosystem you are willing to give up.