pushinbr / pam-http
Elegant HTTP routing and middleware for the Pam runtime.
Requires
- php: ^8.4
- pushinbr/pam-contracts: ^1.1
Requires (Dev)
- illuminate/database: ^13.0
- illuminate/events: ^13.0
- illuminate/filesystem: ^13.0
- illuminate/pagination: ^13.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
Suggests
- illuminate/database: Required by the deprecated built-in Eloquent bridge; use the dedicated PAM database adapter when available.
- illuminate/events: Required by the deprecated built-in Eloquent bridge.
- illuminate/filesystem: Required by the deprecated built-in migration bridge.
- illuminate/pagination: Required by the deprecated built-in Eloquent resource pagination bridge.
- pushinbr/pam-http-psr: PSR-7, PSR-15 and PSR-17 interoperability.
- pushinbr/pam-socket: High-level event and room APIs for Pam WebSockets.
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v2.1.0
- v2.0.1
- v2.0.0
- v1.2.0
- v1.1.0
- v1.0.2
- v1.0.1
- v1.0.0
- v0.1.47
- v0.1.46
- v0.1.45
- v0.1.44
- v0.1.43
- v0.1.42
- v0.1.41
- v0.1.40
- v0.1.39
- v0.1.38
- v0.1.37
- v0.1.36
- v0.1.35
- v0.1.34
- v0.1.33
- v0.1.32
- v0.1.31
- v0.1.30
- v0.1.29
- v0.1.28
- v0.1.27
- v0.1.26
- v0.1.25
- v0.1.24
- v0.1.23
- v0.1.22
- v0.1.21
- v0.1.20
- v0.1.19
- v0.1.18
- v0.1.17
- v0.1.16
- v0.1.15
- v0.1.14
- v0.1.13
- v0.1.12
- v0.1.11
- v0.1.10
- v0.1.9
- v0.1.8
- v0.1.7
- v0.1.6
- v0.1.5
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-brand/pam-mascot
- dev-docs/readme
- dev-wip/pam-http-local-2026-10-08
- dev-perf/offensive-1.0
- dev-feat/api-2-foundation
This package is auto-updated.
Last update: 2026-11-09 16:08:16 UTC
README
Typed HTTP routing and application structure for the PAM runtime.
Routing, middleware, dependency injection, validation, resources, streaming, OpenAPI and production lifecycle controls, running in persistent PHP workers.
Install · Quick example · Features · Docs · Issues
Install
Start a new API with the HTTP template, which already requires pushinbr/pam-http:
pam init my-api --template http
cd my-api
pam dev
In an existing PAM project, add the router with pam composer require pushinbr/pam-http; PAM runs Composer inside its private Embed SAPI. Run pam doctor after dependency changes and before creating a release. The project remains a normal Composer project with a standard manifest, lockfile, PSR-4 autoloading, and vendor/autoload.php.
Quick example
<?php declare(strict_types=1); use Pam\Api\RouteConstraint; use Pam\App; use Pam\Http\Request; use Pam\Http\Response; $app = new App; $app->get('/api/ping', static fn (Request $request, Response $response): Response => $response->json([ 'message' => 'pong', ])); $app->get('/users/{id}', [UserController::class, 'show']) ->where('id', RouteConstraint::Integer) ->name('users.show'); $app->listen((int) (getenv('PAM_PORT') ?: 3000));
Route parameters are available through $request->route(). A path that exists for another method produces 405 behavior; an unknown path produces 404 behavior. Register error handling with onError() and keep transport-level timeouts and request limits in the PAM listener options.
What you can build
- Typed JSON APIs and backend services
- Streaming and event-driven HTTP endpoints
- Structured applications with controllers, services, repositories, and resources
| Role | HTTP framework |
| Execution path | Persistent PHP · PAM transport |
| This repository owns | HTTP routing and application structure |
| Boundary | PAM owns the runtime; databases and framework integrations stay optional |
Features
| Area | What you get | Guide |
|---|---|---|
| Routing | Route groups, prefixes, apiResource, constraints, automatic HEAD and OPTIONS, bounded router limits |
Route groups |
| Container | bind, singleton and request-scoped lifetimes, discarded even when the handler throws |
Container lifetimes |
| Configuration | Typed environment definitions that fail at boot, redacted diagnostics | Typed configuration |
| Validation | FormRequest rules, JsonResource envelopes, Problem Details with stable integer codes |
Validation and resources |
| Security | Rate limiting with pluggable stores, HS256 bearer tokens with key rotation and revocation | Rate limiting, tokens |
| Production | Idempotency, response cache, tenancy, transactions, jobs with leases and dead letters, retries, circuit breakers | Building blocks |
| Observability | Request lifecycle observers and the bounded MemoryProfiler |
Observers |
| Contracts | OpenAPI output and generated TypeScript, Kotlin and Swift clients | OpenAPI |
| Database (optional) | Legacy Eloquent bridge with per-Fiber connections, query budgets, tenant guard | Eloquent ORM |
| Testing | In-memory TestClient from pushinbr/pam-http-testing |
In-memory testing |
Performance contract: compiled hot paths and enforced throughput, tail-latency, startup, and memory budgets.
API guide
| Surface | Use it for |
|---|---|
App |
Register routes, middleware, providers, error boundaries, and the listener. |
Router |
Compile and match method/path routes with typed results. |
Pipeline |
Execute middleware and the destination handler in order. |
CorsMiddleware |
Apply explicit origin, method, and header policy. |
RateLimitMiddleware |
Apply bounded per-key request limits. |
SecurityHeadersMiddleware |
Set conservative browser security headers. |
The public API reference is generated from the reviewed api-surface.json baseline.
Production checklist
- Keep request data and mutable state scoped to the current request.
- Test success, validation failure, exception, cancellation, and timeout paths.
- Configure explicit limits and avoid unbounded payloads, queues, or retained collections.
- Run
pam doctor,pam test, and the relevant integration suite before release. - Validate real dependencies and workload behavior; compatibility is not inferred from package installation alone.
Build hygiene: every local, CI, benchmark, and release build must remove project-scoped regenerable outputs after success or failure. Source, Composer dependencies, and declared evidence are retained. Native consumers inherit PAM's Gradle/Xcode/Rust cleanup contract; this package never deletes another package's artifacts or requires PAM Native.
Troubleshooting notes are in the guide. See CONTRIBUTING.md to contribute (the composer verify quality gate). Report security vulnerabilities through GitHub private vulnerability reporting or the PAM security policy, not a public issue.
Docs
- Official documentation
- Guide: database, routing, container, configuration, validation, security, jobs, observers, OpenAPI, testing
- Architecture
- Performance contract
- Public API reference
- PAM API 2 design and delivery contract
- Upgrade guide
- Changelog
- Package ecosystem
- Runtime compatibility
Part of the PAM ecosystem
PAM runs PHP natively on servers, desktops and phones. This repository is one piece of it.
| PAM | PAM Desktop | PAM Native | Ecosystem |
|---|---|---|---|
| the runtime and CLI | native desktop apps in PHP | native Android and iOS apps in PHP | every official package and plugin |
Docs: push-in.github.io/pam-docs · Issues
Apache License 2.0: use, modify and distribute for any purpose, including commercially · Made in Brazil by Pushin