phprise / grogu-gateway
A generic gateway for Symfony/ApiPlatform applications based on The OTAKU Manifesto.
Package info
github.com/phprise-foundation/grogu-gateway
Type:project
pkg:composer/phprise/grogu-gateway
Requires
- php: ^8.4
- guzzlehttp/psr7: ^2.8
- phprise/common: ^2.0
- phprise/http: ^2.0
Requires (Dev)
- phpunit/phpunit: ^12.5
- vimeo/psalm: ^6.14
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A generic gateway for Symfony/ApiPlatform applications based on the OTAKU Manifesto.
What it does
Grogu is a single entry point in front of many ApiPlatform services. It discovers each service's OpenAPI document at runtime, aggregates every route into one map, and forwards incoming requests to the service that owns the route.
Given enma=https://enma.io and nami=https://nami.io, a request to
POST grogu.io/api/order is forwarded to POST nami.io/api/order.
How it works
- Bootstrap: reads the
GROGU_SERVICESenvironment variable and builds aServiceRegistry. - Discovery: for every service, fetches
{host}/api/docs.jsonand extracts its operations. - Aggregation: builds a
RouteMap. If two services expose the same method and path, anAmbiguousRouteExceptionis thrown and the gateway refuses to start. - Routing: resolves the incoming request against the map and forwards it to the owner.
Discovery happens on every request, so any change in a service's documentation is reflected immediately without restarting the gateway.
Configuration
Services are configured through the GROGU_SERVICES environment variable as a
comma-separated list of name=host pairs:
export GROGU_SERVICES="enma=https://enma.io,nami=https://nami.io,yagami=https://yagami.io"
Different environments can expose different hosts, or omit services entirely (for example, authentication in a development environment).
Running
composer install
GROGU_SERVICES="nami=https://nami.splitpaybrasil.dev.br" php -S localhost:8000 -t public
Testing
vendor/bin/phpunit vendor/bin/psalm
Philosophy
We follow The OTAKU Manifesto: Fluid Structure Design. Please read more about it in PHILOSOPHY.md. See our security policy in SECURITY.md.