amphp / http-server

An advanced async HTTP server library for PHP, perfect for real-time apps and APIs with high concurrency demands.

Home Page:https://amphp.org/http-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC: Add start() and stop() methods to HttpServer interface (v3+)

cspray opened this issue · comments

I'm digging into the 3.0 beta and from a testing perspective I appreciate the HttpServer interface. It allows to more easily write unit tests in addition to integration tests. However, this interface does not include methods to start and stop the server, limiting its usefulness from a testing perspective.

Are the maintainers open to including the existing start() and stop() methods on the SocketHttpServer in the HttpServer interface?

There's been a reason why we haven't added them to the interface. I guess because these methods should only be called by code that "owns" the HTTP server instance, not by code that gets some HttpServer instance injected.

@trowski What's your opinion on this?

@kelunik FWIW the code that has the HttpServer injected is also the code that "owns" the instance. I'm wrapping some other events, route autowiring, and middleware setup before the server itself actually starts. In effect, I want you to be able to bootstrap a Container, get my Application class that wraps all that stuff, and then call $app->start().

good idea

Closed via 0c2b686.