Skip to content
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

Streamlined Request/Response Interface #3029

Open
ipranjal opened this issue Dec 12, 2021 · 5 comments
Open

Streamlined Request/Response Interface #3029

ipranjal opened this issue Dec 12, 2021 · 5 comments

Comments

@ipranjal
Copy link
Contributor

ipranjal commented Dec 12, 2021

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 ?

  1. Create a Request and Response objects from one of the methods given above
  2. Modify Toro to get data from Request object rather than directly accessing super globals
  3. 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
  4. Create &Request() &Response() method to get instance of current request and response object
  5. 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

This was referenced Dec 12, 2021
@lindner
Copy link
Collaborator

lindner commented Jul 12, 2022

Where was this implemented?

@ipranjal ipranjal reopened this Jul 12, 2022
@ipranjal
Copy link
Contributor Author

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

@mediaformat
Copy link
Contributor

mediaformat commented Feb 5, 2024

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 echos with a http-foundation Response across the whole project, however would be out of scope for #3186

@ipranjal
Copy link
Contributor Author

@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

@mediaformat
Copy link
Contributor

I had already started on this, I'll try to publish my WIP branch tomorrow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants