Engine: configuration, context and container
Engine supplies application primitives; HTTP/WS engines and components add request dispatch and integration. Its manifest requires PHP ^8.1, intl/json and Server ^4. A compatible application can have higher transitive PHP requirements.
Container
Section titled “Container”use Triangle\Engine\Container;
$container = new Container();$container->addDefinitions([ 'clock' => static fn (Container $container): object => new stdClass(),]);$clock = $container->get('clock');Definitions are callbacks passed the container; get() caches the result. A zero-argument class can be constructed when no definition exists. has() checks registered definitions/instances rather than all autoconstructible classes. make(class, constructorArgs) creates an instance using positional argument values; it is not recursive reflection autowiring. Do not store per-user mutable state in a cached service. The class implements the PSR container interface, but exception behavior must be reviewed before claiming full PSR-11 conformance.
Configuration and bootstrap
Section titled “Configuration and bootstrap”Config::load/loadAll/reloadAll/clear/get/set manage a filename-keyed tree; see configuration for overlay and route-file behavior. Autoload coordinates CLI/Server startup, includes application files and invokes Bootstrap. Bootstrap calls available middleware/database/session/router/events components and configured bootstrap classes. A component may be absent and skipped, so successful startup alone does not prove it is enabled.
Context, request and response
Section titled “Context, request and response”Context provides get/set/delete/onDestroy/destroy and uses runtime-specific context storage. Treat it as scoped state and verify cleanup for the selected runtime; it is not a durable store. Engine Request/Response extend Server HTTP types, while the selected engine/scaffold can expose Triangle request/response aliases. Use the aliases expected by the installed application when writing controllers.
responseJson() serializes a direct JSON payload; response() may wrap data, choose a view and alter status via http_always_200. Its default JSON flags include JSON_NUMERIC_CHECK: override options when numeric-looking strings such as identifiers must remain strings. Use view() through the View component rather than an invented facade. Helpers require the appropriate application context.
Source declaration index · Components · Compatibility. Engine source revision 89dac7f51f94.