maduser/argon-http

HTTP kernel and response emitter for the Argon runtime stack.

Maintainers

Package info

github.com/judus/argon-http

pkg:composer/maduser/argon-http

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-24 14:35 UTC

This package is auto-updated.

Last update: 2026-05-24 14:39:30 UTC


README

PHP Build codecov Psalm Level Latest Version Downloads License: MIT

maduser/argon-http is the HTTP runtime adapter for Argon applications. It provides the kernel and response emitter that Prophecy can use after the container, routing, middleware, and error packages have been registered.

The package is intentionally small:

  • Kernel runs the HTTP request lifecycle.
  • ResponseEmitter emits PSR-7 responses to SAPI.
  • HttpKernelServiceProvider binds the kernel and emitter into an ArgonContainer.

It does not define routes, build middleware stacks, format exceptions, or create PSR-7 messages. Those responsibilities belong to the routing, middleware, error, and HTTP message packages.

Installation

composer require maduser/argon-http

For a complete HTTP stack, applications normally combine this package with:

  • maduser/argon-prophecy
  • maduser/argon-http-message
  • maduser/argon-routing
  • maduser/argon-middleware
  • maduser/argon-error

Service Provider

Register the HTTP provider during application boot:

use Maduser\Argon\Container\ArgonContainer;
use Maduser\Argon\Http\Provider\HttpKernelServiceProvider;

$container = new ArgonContainer();
$container->register(HttpKernelServiceProvider::class);

The provider binds:

  • Maduser\Argon\Contracts\Handler\AppHandlerInterface to Kernel
  • Psr\Http\Message\ServerRequestInterface through the HTTP message server-request factory
  • Maduser\Argon\Support\Contracts\ResponseEmitterInterface to ResponseEmitter

The server request binding is only registered when the application has not already provided one. It uses a normal factory binding, not a closure, so the container can still be compiled. This keeps tests, workers, and custom front controllers in control while giving normal SAPI front controllers a useful default.

The kernel expects the container to resolve a RequestHandlerInterface. In the full Argon HTTP stack that is usually provided by maduser/argon-routing and maduser/argon-middleware.

Exit Behaviour

By default the provider sets kernel.shouldExit from the runtime environment:

  • APP_ENV=testing disables hard exits.
  • all other environments allow the kernel to exit after emitting a response.

Applications can set kernel.shouldExit before registering the provider to override that default.

Error Handling

The HTTP kernel deliberately does not catch or format exceptions. Runtime throwables are coordinated by Prophecy and the error package so the kernel stays focused on three operations:

  1. process the request through a PSR-15 request handler;
  2. emit the returned PSR-7 response;
  3. terminate with an exit code derived from the response status.