Giter VIP home page Giter VIP logo

Comments (4)

odan avatar odan commented on June 10, 2024 2

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 AMPHP and react/http. These libraries have matured over the years and can be integrated with Slim or any other PHP framework if needed.

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.

from slim.

mikespub avatar mikespub commented on June 10, 2024 1

Oops - sorry, somehow I missed the second version that does exactly that :-(
Nicely done :-)

from slim.

mikespub avatar mikespub commented on June 10, 2024

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)?

from slim.

odan avatar odan commented on June 10, 2024

@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

from slim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.