The Symfony HttpFoundation adapter for the Milpa PHP framework — the response value objects and the base controller a host's routing invokes.
milpa/http describes routes and handlers without committing to any HTTP implementation. This
package is one implementation of the other half: what a controller returns, for a host that
speaks Symfony's HttpFoundation.
It is deliberately small. A host resolves a route to a controller method, calls it with an
HttpFoundation Request, and gets back an HttpResponse. That is the whole contract.
composer require milpa/http-symfony| Class | Responsibility |
|---|---|
HttpResponse |
The response a controller returns — a Symfony Response with the framework's own type, so a host can tell "a Milpa controller answered" from "something else did". |
BlobResponse |
A binary/file response with the download headers already set. |
BaseController |
What a controller extends: the container, plus the shorthands for the answers controllers actually give — json(), cleanResponse(), redirect(), download(). |
use Milpa\Http\HttpMethod;
use Milpa\Http\Routing\Route;
use Milpa\Http\Symfony\BaseController;
use Milpa\Http\Symfony\HttpResponse;
use Symfony\Component\HttpFoundation\Request;
final class HealthController extends BaseController
{
#[Route(path: '/health', methods: HttpMethod::GET, name: 'health')]
public function show(Request $request, array $params = []): HttpResponse
{
return $this->json(['status' => 'ok']);
}
}View rendering. A responder that turns a template into a response needs a template engine, and
that engine is not published yet. Shipping the class anyway would put code in your vendor/ that
cannot run — a package that can only fail is worse than one that is missing a feature. It lives
host-side until the engine earns its own release.
PSR-7. This is the HttpFoundation adapter. A host that speaks PSR-7 end to end does not need it:
milpa/runtime's kernel and milpa/http's router are already PSR-7 native.
- PHP ≥ 8.3
symfony/http-foundation^7.4milpa/core^0.6milpa/http^0.1.5psr/log^3.0
Contributions are welcome — see CONTRIBUTING.md. Please report security issues via SECURITY.md, and note that this project follows a Code of Conduct.
Apache-2.0 © Rodrigo Vicente - TeamX Agency.
Milpa is designed, built, and maintained by Rodrigo Vicente - TeamX Agency.