known
known copied to clipboard
Streamlined Request/Response Interface
What ?
We should probably start using something like https://symfony.com/components/HttpFoundation or PSR 7 implementation like https://github.com/Nyholm/psr7 to work with Request,Response and session and stop using superglobals like $_SERVER , $_REQUEST, $_SESSION etc.
Why ?
While current implementation works good for a apache server it completely kills opportunity for known(idno) to run on faster runtimes like Swoole, Roadrunner or ReactPHP based faster runtime environments
How ?
- Create a Request and Response objects from one of the methods given above
- Modify Toro to get data from Request object rather than directly accessing super globals
- Create a handle() method probably inside Idno/Core/Idno which takes in Request as parameter and returns the Response object after running the whole known flow
- Create &Request() &Response() method to get instance of current request and response object
- handle() method can internally call PageHandler::serve() and other method known utilises
Other Benefits
using echo,echo,echo is never a good idea , if we have a streamlined Response object, before it is served to the user those response can be used by plugin developers to optimize , cache or slightly change the response to suit there needs. Opens up a whole new world of possibility for plugin developers . Also on a side note developing middleware would be possible to tweak Request and Response during the lifecycle of known application
Where was this implemented?
I probably closed it by mistake thinking it to be old stale issue I raised 😅, I was working on a POC , been long will revisit it probably this week
A quick evaluation of the effort, to start using http-foundation Requests for use with landrok/activitypub.
$_SERVER: 122 results across 42 files $_SESSION: 38 results across 6 files $_REQUEST: 19 results across 3 files $_FILES: 26 results across 6 files $_SESSION: 38 results across 6 files
I think replacing the echo
s with a http-foundation Response across the whole project, however would be out of scope for #3186
@mediaformat i am intrested in co-working for sprint 3 to implement request response interface , let me know if you have started , we should work on this in a seprate branch
I had already started on this, I'll try to publish my WIP branch tomorrow