Search by

triangle / engine

localzet

Low-level HTTP engine for Triangle Framework

Package info

github.com/Triangle-org/Engine

pkg:composer/triangle/engine

Statistics

Installs: 1 361

Dependents: 16

Suggesters: 0

Stars: 4

v9.0.1 2026-12-04 18:32 UTC

README

Triangle Engine is the HTTP and application runtime layer used by Triangle Framework projects. It provides request and response objects, configuration and execution context, application bootstrap helpers, and adapters around Localzet Server.

The published v9.0.1 release supports PHP 8.1 or newer and Localzet Server ^7.1. Engine is not a standalone web server: Localzet Server provides the listener, event loop, protocol handling, and process lifecycle.

Requirements

  • PHP ^8.1, ext-intl, and ext-json.
  • localzet/server:^7.1.
  • Monolog ^3.0 and PSR Container ^1.0 or ^2.0.
  • Symfony Cache and Translation ~6.4.0.
Engine version Server requirement Status
v9.0.1 ^7.1 Stable release on Packagist
v8.1.11 ^4 Previous major; incompatible with Server 7

Install the stable release with Composer:

composer require triangle/engine:^9.0
composer show triangle/engine localzet/server

Main components

  • Triangle\Engine\Config loads and reads application configuration.
  • Triangle\Engine\Context stores values for the active Fiber or coroutine; call Context::destroy() when a request or task finishes.
  • Triangle\Engine\Request and Triangle\Engine\Response adapt Localzet Server HTTP messages for Triangle applications.
  • support\App assembles configured listeners and processes for a Triangle application.
  • Triangle\Exception contains the framework exception types and rendering contracts.

Use the application bootstrap already provided by your Triangle project. Engine does not create a listener or choose a deployment topology on its own.

Compatibility with Server 7.1

Server 7 defines global response(), json(), and redirect() helpers. Their names overlap with older Engine helpers but their return values and behavior differ. Engine now exposes explicit names for its own behavior:

Helper Engine behavior With Server 7.1 loaded
triangle_response() Engine response envelope and content negotiation Use this to retain Engine behavior
triangle_json() Encodes a PHP value as a JSON string Use this when a string is needed
triangle_redirect() Returns Triangle\Engine\Response and strips CR/LF from the location Use this when Engine's response type is required
responseJson() / responseBlob() Build an Engine response Keep using these helpers

The unprefixed names resolve to Server's helpers when Server is loaded first. This source guards its optional legacy declarations so Composer autoload does not redeclare those functions. Update direct application calls to response(), json(), or redirect() when they relied on Engine-specific semantics. Environment variables should be read with triangle_env($key, $default) when typed boolean and numeric values are needed. The generic global env() may be supplied by another Composer dependency, such as Illuminate, and can return raw strings instead of Engine's parsed values.

Migrating Engine 8 helper calls

Engine 8 call Engine 9 replacement Return contract
json($data) triangle_json($data) JSON string
response($data, $status) triangle_response($data, $status) Engine response envelope and content negotiation
redirect($url, $status) triangle_redirect($url, $status) Triangle\Engine\Response

If the application needs a JSON HTTP response without the Engine envelope, use responseJson($data, $status). Calls without the triangle_ prefix now follow the Server 7 contract, so update the call site according to whether it needs a string, an Engine response, or a Server response.

The current Context implementation keys storage by the active PHP Fiber regardless of the selected event-loop class. This matters when asynchronous handlers interleave on Server 7's standard event loops.

Tests

Install the development dependencies and run the declared PHPUnit suite:

composer install
composer test

The suite covers configuration, Fiber context isolation, Server 7 helper interoperability, and a real loopback HTTP request through Server 7 using the Engine request and response classes. It does not replace application-level tests for routing, middleware, storage, or deployment behavior.

Documentation and support

Copyright © 2016-2026 Localzet Group. All rights reserved.