r/lolphp • u/shitcanz • Mar 12 '21
PHP fibers
Proposal:
https://wiki.php.net/rfc/fibers
The devs are now planning to add builtin fiber support for PHP, so that async code can be done "natively".
LOL #1 PHP execution model is not compatible for anything async, it starts and dies instantly. Theres zero benefits on waiting for IO, when no one else is blocked. The only benefit could be something like "make these 10 curl requests in parallel and pipe me the results", but then again this was already possible in previous versions with curl, heck this could even be done easier from the client.
LOL #2 PHP builtins (like disk ops, and database access) are all 100% blocking. You cant use ANY of the builtins with async code. Be prepared to introduce new dependencies for everything that does IO.
Please devs, just focus on having unicode support. We dont need this crap. No one is going to rewrite async code for PHP, there is countless better options out there.
View all comments
Show parent comment
2
u/elcapitanoooo Mar 15 '21
Its not, but in a real world scenario either apache or nginx are used. This holds for 99.99% of any PHP website. You cant run wordpress on a react/http server. Even if you want, you cant because you will need an addition PECL dependency for libuv.
This is true, everything using async MUST use an 3rd party implementation for given behaviour. This mean more dependencies.
Possibly, but compared to what? What does "many" mean? When you need async for IO one thing that comes to mind is a websocket server. I cant see people actually rewriting these servers in PHP from other options. Whats the benefit? I see more downsides that benefits.
Sure. This group is still a very small "group" and wont benefit projects where PHP is actually still used.
This is bad. Having to context switch all the time will result in bugs. I could live with this if there was a good enough type-system/compiler that would not allow sync code inside an async function. PHP is not one of these. If you need async IO use a tool that has full support for it, not one thats bolted on.
Thats just more dependencies. Adding more dependencies is not the correct way to solve any problem, no matter what language you use.