New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP8 Fibers Discussion #3289
Comments
Hi! Here are some thoughts. The introduction of Fibers in PHP 8 is indeed an exciting feature, allowing for more elegant cooperative multitasking. It has the potential to transform how we handle asynchronous operations in PHP. However, it's essential to consider PHP's inherent shared-nothing architecture. This architecture means that each request starts with a clean state, without any shared state from the previous requests. While this model simplifies concurrency and reduces concerns about thread safety, it can pose challenges when implementing asynchronous features like Fibers. That said, Slim Framework, being a micro-framework, is primarily designed to provide the minimal essentials to quickly build web applications. Its philosophy revolves around staying lightweight and leaving additional features to be handled by third-party libraries. While Fibers offer a fresh approach to concurrency, it's worth noting that asynchronous functionality can already be achieved in PHP using libraries like I have already blogged about this topic and made some performance tests. The results were impressive, but in practice it was hard to manage because everything (IO, database access) needs to be asynchronous then. But PHP itself is not build for that, and the support in the PHP community is not that big in this area. In essence, while Fibers could be a boost for some projects, the integration of such features might be beyond the intended scope of a micro-framework like Slim. |
As a micro-framework the question should rather be: is there anything in how Slim handles requests that would stop someone from using it as part of a larger application running on AMPHP/ReactPHP/Swoole/...? In other words, if you created the app once and then let it handle requests concurrently, what would accidently leak between requests or block them unnecessarily? The example I found for Slim 4 e.g. on https://discourse.slimframework.com/t/slim4-micro-services-reactphp-html-server/4914 still creates a new app instance for each request, which may work OK but hardly makes it "compatible" Older experiments with Slim 3 like https://github.com/mbarquin/reactphp-slim show that (at that point) Slim required some tweaks to make it work as intended. How are we today (or tomorrow)? |
@mikespub As far as I know, there are no tweaks needed to make Slim 4 "compatible" with ReactPHP. It works if you create the Slim App instance as shown here: https://discourse.slimframework.com/t/slim4-micro-services-reactphp-html-server/4914/2?u=odan |
Oops - sorry, somehow I missed the second version that does exactly that :-( |
Have you already thought about the benefits of PHP8 and the Fibers feature?
It could really be a boost for Slim.
The text was updated successfully, but these errors were encountered: