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

Allow custom ReactPHP middlewares #439

Closed
acasademont opened this issue Nov 9, 2018 · 14 comments
Closed

Allow custom ReactPHP middlewares #439

acasademont opened this issue Nov 9, 2018 · 14 comments

Comments

@acasademont
Copy link
Contributor

For example, right now we can't do Gzip compression directly from PHP-PM, we need a web server to do that for us. Not sure how could we implement this. At some point I feel we should start reading a php-pm.config.json file instead of having the huge amount of CLI options we have right now.

@marcj
Copy link
Member

marcj commented Nov 9, 2018

Yeah custom middlewares would be good. However, we have already a ppm.json, which is basically the same as all CLI options. See https://github.com/php-pm/php-pm/blob/master/src/Commands/ConfigTrait.php#L82

@acasademont
Copy link
Contributor Author

@marcj my apologies then, hadn't even seen it 🤦‍♂️ An array of middlewares could be easily configured then

@dnna
Copy link
Contributor

dnna commented Nov 9, 2018

I'm not sure if its PHP-PM's job to do this. AFAIK its not meant to replace a real web server, only to do what FPM used to do.

@acasademont
Copy link
Contributor Author

@dnna yes, I agree, I don't expect PHP-PM to handle SSL termination, for examples. Maybe the gzip example was a bad one, there could be other useful middlewares. For example, there's a Static files middleware that we could reuse instead of having our own.

https://github.com/reactphp/http/wiki/Middleware

@andig
Copy link
Contributor

andig commented Feb 4, 2019

Maybe this would be a good opportunity to approach this for 2.1 or 2.0? Do we agree that middlewares should be handled by the slaves, not the master?

@acasademont
Copy link
Contributor Author

@andig It could also work on the master, yeah, might be easier maybe and middlewares like the static files one probably make more sense in master?

@acasademont
Copy link
Contributor Author

mmm, ammending my own comment, we only start the reactphp HttpServer on the slaves, master just opens the socket and distributes the requests load among the slaves, never really touches the Http layer. Therefore, middlewares should go on the slaves if we want to keep the current architecture.

@dnna
Copy link
Contributor

dnna commented Feb 5, 2019

I think the current architecture makes sense - IMO the master shouldn't do much more than distribute requests and ensure that the slaves are running. This way the system can scale by simply adding more workers, who are responsible for doing the actual work. Most of the middlewares I see on the page make sense to run on the slave, except the websocket one which would probably be a big milestone by itself.

@acasademont
Copy link
Contributor Author

acasademont commented Feb 5, 2019

Yep. Also, things like Keep Alive or Http2 that the ReactPHP guys were working on (reactphp/http#39 reactphp/http#99) would probably mean the http server needs to be started on master too and the slaves are just piping back and forth a simple request/response

@andig
Copy link
Contributor

andig commented Mar 20, 2019

Closing here in alignment with discussion in #146 php-pm/php-pm-httpkernel#146.

@andig andig closed this as completed Mar 20, 2019
@acasademont
Copy link
Contributor Author

Sorry but I don't get it, what does the amphp discussion have to do with this? I'm happy to work on this feature (eventually)

@andig
Copy link
Contributor

andig commented Mar 20, 2019

Sorry but I don't get it, what does the amphp discussion have to do with this?

Absolutely nothing :O. Didn't realize that your PR was in httpkernel, sorry.

@acasademont
Copy link
Contributor Author

hahaha gotcha, still, i don't think the 2 features were related, no?

@andig
Copy link
Contributor

andig commented Mar 20, 2019

My thinking was that- if we were using Middleware's interface from PSR15 in php-pm/php-pm-httpkernel#146 then that would already be a first step into customer middlewares, so they are at least related or one is a precondition for the other?

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

No branches or pull requests

4 participants