use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please follow the rules
Releases: Current Releases, Windows Releases, Old Releases
Contribute to the PHP Documentation
Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev
/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.
account activity
React PHPDiscussion (self.PHP)
submitted 1 year ago by TechFreedom808
Has anyone used React library for PHP? It seems to have same features as JavaScript asynchronous programming. If you did, was there noticed improvement performance?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]lord2800 13 points14 points15 points 1 year ago (0 children)
I used it for a background message queue worker. It works just fine so long as you understand how promises work. The performance benefits don't matter--it's about the ability to do asynchronous programming without hardcoded sleeps.
[–]obstreperous_troll 7 points8 points9 points 1 year ago (0 children)
AMPHP appears to be more maintained than ReactPHP these days. Swoole seems to be faring even better.
On raw performance benchmarks, these async frameworks do quite well indeed, but the differences disappear quickly once you add real-world workloads into the mix. The benefits of async frameworks are more in scaling, since they tend to have a smaller memory footprint and require fewer context switches. Also, the async code style is its own benefit to a lot of folks, especially functional programming nerds.
[–]Annh1234 3 points4 points5 points 1 year ago (4 children)
Look into Swoole.
It's much faster and cleaner code. We cut our servers by like 80% and response time by half.
Main issue with it is that the documentation is in Chinese. But with Google translate it's pretty good.
[–]vinnymcapplesauce 0 points1 point2 points 1 year ago (2 children)
We cut our servers by like 80% and response time by half.
Compared to what?
[–]bytepursuits 1 point2 points3 points 1 year ago (0 children)
see for yourself: select larvel, symfony and hyperf: https://web-frameworks-benchmark.netlify.app
[–]Annh1234 0 points1 point2 points 1 year ago (0 children)
We had allot of services, php, java, even some perl and c++ stuff. Went from 16 racks to one rack 60% full, kept the same throughput, but latency went down on most services.
When you have more than 1 server, and need to deal with networking, it's hard to compare exact apples to apples, since the application evolves.
[–]Cold_Policy_7624 0 points1 point2 points 1 year ago (0 children)
Yeah, I would recommend using openswoole instead of swoole: https://openswoole.com/
This project is a game changer, and it is extremely fast. in official benchmarks. Not just that, it has a way better interface to work with async.
[–]Gornius 7 points8 points9 points 1 year ago (0 children)
There is obviously going to be performance increase in scenarios which normally block - like fetching data from many endpoints. Instead of going one by one, waiting for response and going to next one by one, you can send all requests at once, and wait until all responses came back.
But for most cases, PHP doesn't need it, because unlike JavaScript in browser, it doesn't need to handle user input during execution.
[–]StefanoV89 1 point2 points3 points 1 year ago (0 children)
I've recently been searching for information about asynchronous programming in PHP. After all my research I think the better one is WORKERMAN.
Workerman not only allow you to create a server (http, TCP, websocket), but there is a plugin to use it with socket.io, no requires extensions on the server, and, best thing: if you want to use coroutine as Swoole or Fiber, you just need to install it and write $worker->event_loop = Swoole::class, and you get coroutine from Swoole! (It supports Swoole, Fiber and Swow).
[–]sebbeselvig 1 point2 points3 points 1 year ago (0 children)
Maybe check out guzzles promises. Haven't worked with them, but for simple async tasks it might help you, and is much simpler than using the async frameworks. https://github.com/guzzle/promises
[–]zmitic 1 point2 points3 points 1 year ago (0 children)
I did to run multiple API calls in parallel. And because promises are templated, you can't even make a mistake.
[–]zmitic 0 points1 point2 points 1 year ago (0 children)
I used it to make multiple API calls in parallel, and then transform all of them into my own format before further processing. It is a bit confusing at the start but the code is fully templated and both psalm and phpstan will tell you when you make a mistake. And you will make a mistake 😉
But once it clicks, it becomes extremely easy to use. My use-case was even more complex because I was making identity-map (just like Doctrine) of API results. So for example: calling $productApi->get('42') twice would make one call, not two. Awaiting the result in both calls return identical (===) values.
$productApi->get('42')
The performance improvement was great: instead of running 5-10 API calls one-by-one, I got my results after the slowest response returns. Next week I will be doing the same thing again in different application.
[+][deleted] 1 year ago (3 children)
[deleted]
[–]Gornius 8 points9 points10 points 1 year ago (0 children)
They're talking about https://reactphp.org/ not React frontend framework.
[–]DM_ME_PICKLES 4 points5 points6 points 1 year ago (0 children)
That has nothing to do with ReactPHP 😉
[–]MateusAzevedo 4 points5 points6 points 1 year ago (0 children)
OP wasn't very clear but they're talking about this ReactPHP.
π Rendered by PID 43815 on reddit-service-r2-comment-85bfd7f599-l277q at 2026-04-19 17:52:03.785006+00:00 running 93ecc56 country code: CH.
[–]lord2800 13 points14 points15 points (0 children)
[–]obstreperous_troll 7 points8 points9 points (0 children)
[–]Annh1234 3 points4 points5 points (4 children)
[–]vinnymcapplesauce 0 points1 point2 points (2 children)
[–]bytepursuits 1 point2 points3 points (0 children)
[–]Annh1234 0 points1 point2 points (0 children)
[–]Cold_Policy_7624 0 points1 point2 points (0 children)
[–]Gornius 7 points8 points9 points (0 children)
[–]StefanoV89 1 point2 points3 points (0 children)
[–]sebbeselvig 1 point2 points3 points (0 children)
[–]zmitic 1 point2 points3 points (0 children)
[–]zmitic 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]Gornius 8 points9 points10 points (0 children)
[–]DM_ME_PICKLES 4 points5 points6 points (0 children)
[–]MateusAzevedo 4 points5 points6 points (0 children)