diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml
index d521c32..32ea944 100644
--- a/.github/workflows/php.yml
+++ b/.github/workflows/php.yml
@@ -18,6 +18,7 @@ jobs:
fail-fast: false
matrix:
php: ['8.1', '8.5']
+ engine: ['8.1.11', '9.0.0']
steps:
- name: Checkout
uses: actions/checkout@v7
@@ -31,11 +32,14 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
coverage: none
- - name: Validate Composer manifest and lock
+ - name: Validate Composer manifest
run: composer validate --no-check-publish --no-interaction
- - name: Install locked dependencies
- run: composer install --prefer-dist --no-interaction --no-progress --no-scripts
+ - name: Resolve dependencies for Engine version
+ run: composer update --prefer-dist --no-interaction --no-progress --with=triangle/engine:${{ matrix.engine }}
+
+ - name: Audit locked dependencies
+ run: composer audit --locked --no-interaction
- name: Check PHP syntax
run: find . -path './vendor' -prune -o -path './.git' -prune -o -name '*.php' -type f -print0 | xargs -0 -n1 php -l
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d2455d2..60c10b3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,28 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-## [1.0.0] - 2025-01-XX - LTS Release
+## [2.1.0] - Unreleased
### Added
-- Initial LTS release
-- Full documentation
-- Template rendering system
-- Multiple template engine support
-- View caching
-- View composers
-- Layout system
-- Blade template support
+- Support Triangle Engine 9 while retaining compatibility with Engine 8.
+- Add an Engine-backed integration check for view configuration and template rendering.
-### Changed
-- Improved template rendering performance
-- Enhanced view caching
-
----
-
-## [Unreleased]
-
-### Planned
-- Additional template engines
-- View component system
-- Improved caching strategy
+### Fixed
+- Include request-assigned variables in the default PHP renderer.
+- Return and deduplicate post-render templates separately from pre-render templates.
diff --git a/README.md b/README.md
index 4336e1a..5ec0cf7 100644
--- a/README.md
+++ b/README.md
@@ -19,3 +19,35 @@
+
+# Triangle View
+
+Triangle View provides a small adapter layer for rendering PHP templates and, when installed, Blade, Twig, or ThinkPHP templates.
+
+## Compatibility
+
+- PHP 8.1 or newer.
+- Triangle Engine `^8.1` or `^9.0`.
+- Engine 9 runs on Localzet Server 7; Engine 8 remains supported for existing applications.
+
+Install the package with Composer:
+
+```sh
+composer require triangle/view:^2.1
+```
+
+The package's `Install` helper copies the default `view.php` configuration into the application's config directory when it does not already exist. The default handler is `raw`; set `VIEW_HANDLER` to `blade`, `twig`, or `think` to select an optional adapter. Install the corresponding template engine package separately.
+
+By default, a template named `page` for the `dashboard` application is loaded from `app/dashboard/view/page.phtml`. The `view()` helper returns an Engine response and merges variables assigned to the current request with the variables passed to the helper; explicit helper variables take precedence.
+
+The `raw` handler executes PHP templates and does not escape output automatically. Escape untrusted values in the template, for example with `htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8')`.
+
+Run the Engine compatibility and rendering integration check with:
+
+```sh
+composer test
+```
+
+For Russian documentation, see [README.ru.md](README.ru.md).
+
+Copyright © 2016-2026 [Localzet Group](https://www.localzet.com/). All rights reserved.
diff --git a/README.ru.md b/README.ru.md
new file mode 100644
index 0000000..a5f897d
--- /dev/null
+++ b/README.ru.md
@@ -0,0 +1,31 @@
+# Triangle View
+
+Triangle View предоставляет небольшой слой адаптеров для PHP-шаблонов и, при установленной зависимости, для Blade, Twig или ThinkPHP.
+
+## Совместимость
+
+- PHP 8.1 или новее.
+- Triangle Engine `^8.1` или `^9.0`.
+- Engine 9 работает на Localzet Server 7; поддержка Engine 8 сохранена для существующих приложений.
+
+Установите пакет через Composer:
+
+```sh
+composer require triangle/view:^2.1
+```
+
+Класс `Install` копирует конфигурацию `view.php` в каталог конфигурации приложения, если файла там ещё нет. По умолчанию используется обработчик `raw`; переменная `VIEW_HANDLER` со значением `blade`, `twig` или `think` выбирает соответствующий необязательный адаптер. Установите пакет выбранного шаблонизатора отдельно.
+
+По умолчанию шаблон `page` приложения `dashboard` загружается из `app/dashboard/view/page.phtml`. Помощник `view()` возвращает ответ Engine и объединяет переменные текущего запроса с параметрами вызова; явные параметры имеют приоритет.
+
+Обработчик `raw` исполняет PHP-шаблоны и не экранирует вывод автоматически. Экранируйте недоверенные значения в шаблоне, например через `htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8')`.
+
+Запуск интеграционной проверки Engine и рендеринга:
+
+```sh
+composer test
+```
+
+English version: [README.md](README.md).
+
+Copyright © 2016-2026 [Localzet Group](https://www.localzet.com/). All rights reserved.
diff --git a/composer.json b/composer.json
index 80a1d69..2b3d370 100644
--- a/composer.json
+++ b/composer.json
@@ -34,9 +34,12 @@
"require-dev": {
"rector/rector": "*"
},
+ "scripts": {
+ "test": "php tests/engine_compatibility.php"
+ },
"require": {
"php": "^8.1",
- "triangle/engine": "^8.1"
+ "triangle/engine": "^8.1 || ^9.0"
},
"suggest": {
"twig/twig": "For Twig render",
diff --git a/rector.php b/rector.php
index 681dd87..155ed66 100644
--- a/rector.php
+++ b/rector.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Config/view.php b/src/Config/view.php
index 216d41a..94e6f27 100644
--- a/src/Config/view.php
+++ b/src/Config/view.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
@@ -31,7 +32,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2024 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Install.php b/src/Install.php
index 94ef4b4..8f18777 100644
--- a/src/Install.php
+++ b/src/Install.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Render/AbstractRender.php b/src/Render/AbstractRender.php
index a134b6e..9b2ca98 100644
--- a/src/Render/AbstractRender.php
+++ b/src/Render/AbstractRender.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
@@ -115,7 +116,7 @@ public static function addPreRender(string $template, string $app = null, string
*/
public static function getPreRenders(): array
{
- return array_unique(self::$preRender);
+ return array_values(array_unique(self::$preRender, SORT_REGULAR));
}
/**
@@ -138,6 +139,6 @@ public static function addPostRender(string $template, string $app = null, strin
*/
public static function getPostRenders(): array
{
- return array_unique(self::$preRender);
+ return array_values(array_unique(self::$postRender, SORT_REGULAR));
}
-}
\ No newline at end of file
+}
diff --git a/src/Render/Blade.php b/src/Render/Blade.php
index 374aa41..2d92119 100644
--- a/src/Render/Blade.php
+++ b/src/Render/Blade.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Render/Raw.php b/src/Render/Raw.php
index 98c8caa..a5f065b 100644
--- a/src/Render/Raw.php
+++ b/src/Render/Raw.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
@@ -51,6 +52,7 @@ class Raw extends AbstractRender implements RenderInterface
*/
public static function render(string $template, array $vars, string $app = null, string $plugin = null): string
{
+ $request = request();
$configPrefix = $plugin ? config('app.plugin_alias', 'plugin') . ".$plugin." : '';
foreach (config("{$configPrefix}view.options.pre_renders", []) as $render) {
diff --git a/src/Render/RenderInterface.php b/src/Render/RenderInterface.php
index ebe987b..39bc124 100644
--- a/src/Render/RenderInterface.php
+++ b/src/Render/RenderInterface.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Render/ThinkPHP.php b/src/Render/ThinkPHP.php
index 614f124..b2080c8 100644
--- a/src/Render/ThinkPHP.php
+++ b/src/Render/ThinkPHP.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Render/Twig.php b/src/Render/Twig.php
index 4d19983..75d3885 100644
--- a/src/Render/Twig.php
+++ b/src/Render/Twig.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/Support/View.php b/src/Support/View.php
index 606e15a..9690f37 100644
--- a/src/Support/View.php
+++ b/src/Support/View.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/src/functions.php b/src/functions.php
index 1dae866..fc0a15d 100644
--- a/src/functions.php
+++ b/src/functions.php
@@ -5,7 +5,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2025 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
@@ -31,7 +32,8 @@
* @link https://github.com/Triangle-org/View
*
* @author Ivan Zorin
- * @copyright Copyright (c) 2023-2024 Triangle Framework Team
+ * @copyright Copyright © 2016-2026 Localzet Group. All rights reserved.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
* @license https://www.gnu.org/licenses/agpl-3.0 GNU Affero General Public License v3.0
*
* This program is free software: you can redistribute it and/or modify
diff --git a/tests/engine_compatibility.php b/tests/engine_compatibility.php
new file mode 100644
index 0000000..c39e783
--- /dev/null
+++ b/tests/engine_compatibility.php
@@ -0,0 +1,130 @@
+getPathname());
+ }
+
+ rmdir($path);
+}
+
+$basePath = sys_get_temp_dir() . '/triangle-view-engine-' . bin2hex(random_bytes(8));
+$configPath = "$basePath/config";
+$appPath = "$basePath/app";
+$viewPath = "$appPath/dashboard/view";
+$runtimePath = "$basePath/runtime";
+
+foreach ([$configPath, $viewPath, $runtimePath, "$basePath/public"] as $directory) {
+ mkdir($directory, 0700, true);
+}
+
+Path::$basePath = $basePath;
+Path::$configPath = $configPath;
+Path::$appPath = $appPath;
+Path::$publicPath = "$basePath/public";
+Path::$runtimePath = $runtimePath;
+
+file_put_contents(
+ "$configPath/server.php",
+ " " . var_export(EngineCompatibilityRequestProvider::class, true) . "];\n",
+);
+
+Config::clear();
+Config::load($configPath);
+
+ob_start();
+Install::install();
+ob_end_clean();
+
+check(is_file("$configPath/view.php"), 'Install did not copy the default view configuration.');
+
+Config::clear();
+Config::load($configPath);
+
+check(config('view.handler') === Raw::class, 'Engine configuration did not register the default renderer.');
+
+if (!class_exists(\Triangle\Request::class)) {
+ class_alias(Request::class, \Triangle\Request::class);
+}
+
+if (!class_exists(\Triangle\Response::class)) {
+ class_alias(\Triangle\Engine\Response::class, \Triangle\Response::class);
+}
+
+$request = new Request('');
+$request->app = 'dashboard';
+EngineCompatibilityRequestProvider::$request = $request;
+
+file_put_contents("$viewPath/prefix.phtml", 'prefix|');
+file_put_contents(
+ "$viewPath/page.phtml",
+ '= htmlspecialchars($title, ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8") ?>'
+ . '|= htmlspecialchars($shared, ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8") ?>'
+ . '|= htmlspecialchars($override, ENT_QUOTES | ENT_SUBSTITUTE, "UTF-8") ?>'
+ . '|= $raw ?>|',
+);
+file_put_contents("$viewPath/suffix.phtml", '|suffix');
+
+View::assign('shared', 'from request & ');
+View::assign('override', 'request value');
+AbstractRender::addPreRender('prefix', 'dashboard');
+AbstractRender::addPreRender('prefix', 'dashboard');
+AbstractRender::addPostRender('suffix', 'dashboard');
+AbstractRender::addPostRender('suffix', 'dashboard');
+
+$response = view('page', [
+ 'title' => 'A&B',
+ 'override' => 'helper wins',
+ 'raw' => 'raw template output',
+], 'dashboard');
+$expected = 'prefix|A&B|from request & <tag>|helper wins|'
+ . 'raw template output||suffix';
+
+check($response instanceof \Triangle\Response, 'The view helper did not return the Engine response type.');
+check($response->rawBody() === $expected, 'The renderer lost assigned variables, escaping, or post-render templates.');
+
+Config::clear();
+EngineCompatibilityRequestProvider::$request = null;
+removeTree($basePath);
+
+echo "ENGINE_VIEW_COMPATIBILITY=ok\n";
+echo 'TRIANGLE_ENGINE_VERSION=' . (Composer\InstalledVersions::getPrettyVersion('triangle/engine') ?? 'unknown') . "\n";