diff --git a/app.php b/app.php index 5f1280be..9224796a 100644 --- a/app.php +++ b/app.php @@ -2,11 +2,11 @@ use Grocy\Controllers\ExceptionController; use Grocy\Helpers\UrlManager; +use Grocy\Helpers\SlimBladeView; use Grocy\Middleware\LocaleMiddleware; use Grocy\Middleware\CorsMiddleware; use Psr\Container\ContainerInterface as Container; use Slim\Factory\AppFactory; -use Slim\Views\Blade; // Load composer dependencies require_once __DIR__ . '/packages/autoload.php'; @@ -84,7 +84,7 @@ $app = AppFactory::create(); $container = $app->getContainer(); $container->set('view', function (Container $container) { - return new Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache'); + return new SlimBladeView(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache'); }); $container->set('UrlManager', function (Container $container) diff --git a/composer.json b/composer.json index 147c69fc..3ddd35c9 100644 --- a/composer.json +++ b/composer.json @@ -1,20 +1,20 @@ { "require": { "php": "8.5.*", - "slim/slim": "^4.0", - "slim/psr7": "^1.0", - "slim/http": "^1.0", - "php-di/php-di": "^7.0.3", - "berrnd/slim-blade-view": "^1.0.0", - "morris/lessql": "dev-php82", - "gettext/gettext": "dev-4.x-fork", "eluceo/ical": "^2.2.0", "erusev/parsedown": "^1.7", - "gumlet/php-image-resize": "^2.0", "ezyang/htmlpurifier": "^4.13", - "interficieis/php-barcode": "^2.0.2", + "gettext/gettext": "dev-4.x-fork", + "gumlet/php-image-resize": "^2.0", "guzzlehttp/guzzle": "^7.0", - "mike42/escpos-php": "^4.0" + "interficieis/php-barcode": "^2.0.2", + "mike42/escpos-php": "^4.0", + "morris/lessql": "dev-master-fork", + "php-di/php-di": "^7.0.3", + "slim/http": "^1.0", + "slim/psr7": "^1.0", + "slim/slim": "^4.0", + "webman/blade": "^1.5" }, "repositories": [ { diff --git a/composer.lock b/composer.lock index dc2a78dd..45bc63a3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,125 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ef8208c97da190ec7d138910f95733f2", + "content-hash": "05efe482aa5f20f8a18e6be376ac3562", "packages": [ - { - "name": "berrnd/slim-blade-view", - "version": "v1.2.1", - "source": { - "type": "git", - "url": "https://github.com/berrnd/slim-blade-view.git", - "reference": "cf8a5718e0804801230d41d2f9a44e00a0d49376" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/berrnd/slim-blade-view/zipball/cf8a5718e0804801230d41d2f9a44e00a0d49376", - "reference": "cf8a5718e0804801230d41d2f9a44e00a0d49376", - "shasum": "" - }, - "require": { - "psr/http-message": "^1.0", - "ramsey/uuid": "^4.1.1", - "webman/blade": "^1.5.4" - }, - "require-dev": { - "phpunit/phpunit": "^4.0", - "slim/slim": "^4.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Slim\\Views\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernd Bestel", - "email": "bernd@berrnd.de" - }, - { - "name": "Hiroaki Matsuura", - "email": "lib2jp@gmail.com" - } - ], - "description": "Fork of rubellum/Slim-Blade-View with Slim Framework v4 and Laravel Blade Templates v11 support", - "keywords": [ - "blade", - "framework", - "renderer", - "slim", - "template", - "view" - ], - "support": { - "source": "https://github.com/berrnd/slim-blade-view/tree/v1.2.1" - }, - "time": "2025-01-21T17:26:52+00:00" - }, - { - "name": "brick/math", - "version": "0.14.8", - "source": { - "type": "git", - "url": "https://github.com/brick/math.git", - "reference": "63422359a44b7f06cae63c3b429b59e8efcc0629" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/63422359a44b7f06cae63c3b429b59e8efcc0629", - "reference": "63422359a44b7f06cae63c3b429b59e8efcc0629", - "shasum": "" - }, - "require": { - "php": "^8.2" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.2", - "phpstan/phpstan": "2.1.22", - "phpunit/phpunit": "^11.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Brick\\Math\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Arbitrary-precision arithmetic library", - "keywords": [ - "Arbitrary-precision", - "BigInteger", - "BigRational", - "arithmetic", - "bigdecimal", - "bignum", - "bignumber", - "brick", - "decimal", - "integer", - "math", - "mathematics", - "rational" - ], - "support": { - "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.14.8" - }, - "funding": [ - { - "url": "https://github.com/BenMorel", - "type": "github" - } - ], - "time": "2026-02-10T14:33:43+00:00" - }, { "name": "carbonphp/carbon-doctrine-types", "version": "3.2.0", @@ -1945,16 +1828,16 @@ }, { "name": "morris/lessql", - "version": "dev-php82", + "version": "dev-master-fork", "source": { "type": "git", "url": "https://github.com/berrnd/lessql.git", - "reference": "6e119fcf0e8145cd9b5e22fe030e147655acc4e3" + "reference": "bab1170a299ac39c63cb87abf8d1c3fc0cfe0b8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/berrnd/lessql/zipball/6e119fcf0e8145cd9b5e22fe030e147655acc4e3", - "reference": "6e119fcf0e8145cd9b5e22fe030e147655acc4e3", + "url": "https://api.github.com/repos/berrnd/lessql/zipball/bab1170a299ac39c63cb87abf8d1c3fc0cfe0b8c", + "reference": "bab1170a299ac39c63cb87abf8d1c3fc0cfe0b8c", "shasum": "" }, "require": { @@ -1964,6 +1847,7 @@ "friendsofphp/php-cs-fixer": "^2.16", "phpunit/phpunit": "~4.6|~5|~6|~7" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -1997,9 +1881,9 @@ "sql" ], "support": { - "source": "https://github.com/berrnd/lessql/tree/php82" + "source": "https://github.com/berrnd/lessql/tree/master-fork" }, - "time": "2023-08-01T19:13:22+00:00" + "time": "2026-03-04T18:42:48+00:00" }, { "name": "nesbot/carbon", @@ -2494,16 +2378,16 @@ }, { "name": "psr/http-message", - "version": "1.1", + "version": "2.0", "source": { "type": "git", "url": "https://github.com/php-fig/http-message.git", - "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba" + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba", - "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", "shasum": "" }, "require": { @@ -2512,7 +2396,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -2527,7 +2411,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interface for HTTP messages", @@ -2541,9 +2425,9 @@ "response" ], "support": { - "source": "https://github.com/php-fig/http-message/tree/1.1" + "source": "https://github.com/php-fig/http-message/tree/2.0" }, - "time": "2023-04-04T09:50:52+00:00" + "time": "2023-04-04T09:54:51+00:00" }, { "name": "psr/http-server-handler", @@ -2803,160 +2687,6 @@ }, "time": "2019-03-08T08:55:37+00:00" }, - { - "name": "ramsey/collection", - "version": "2.1.1", - "source": { - "type": "git", - "url": "https://github.com/ramsey/collection.git", - "reference": "344572933ad0181accbf4ba763e85a0306a8c5e2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ramsey/collection/zipball/344572933ad0181accbf4ba763e85a0306a8c5e2", - "reference": "344572933ad0181accbf4ba763e85a0306a8c5e2", - "shasum": "" - }, - "require": { - "php": "^8.1" - }, - "require-dev": { - "captainhook/plugin-composer": "^5.3", - "ergebnis/composer-normalize": "^2.45", - "fakerphp/faker": "^1.24", - "hamcrest/hamcrest-php": "^2.0", - "jangregor/phpstan-prophecy": "^2.1", - "mockery/mockery": "^1.6", - "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.4", - "phpspec/prophecy-phpunit": "^2.3", - "phpstan/extension-installer": "^1.4", - "phpstan/phpstan": "^2.1", - "phpstan/phpstan-mockery": "^2.0", - "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^10.5", - "ramsey/coding-standard": "^2.3", - "ramsey/conventional-commits": "^1.6", - "roave/security-advisories": "dev-latest" - }, - "type": "library", - "extra": { - "captainhook": { - "force-install": true - }, - "ramsey/conventional-commits": { - "configFile": "conventional-commits.json" - } - }, - "autoload": { - "psr-4": { - "Ramsey\\Collection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ben Ramsey", - "email": "ben@benramsey.com", - "homepage": "https://benramsey.com" - } - ], - "description": "A PHP library for representing and manipulating collections.", - "keywords": [ - "array", - "collection", - "hash", - "map", - "queue", - "set" - ], - "support": { - "issues": "https://github.com/ramsey/collection/issues", - "source": "https://github.com/ramsey/collection/tree/2.1.1" - }, - "time": "2025-03-22T05:38:12+00:00" - }, - { - "name": "ramsey/uuid", - "version": "4.9.2", - "source": { - "type": "git", - "url": "https://github.com/ramsey/uuid.git", - "reference": "8429c78ca35a09f27565311b98101e2826affde0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/8429c78ca35a09f27565311b98101e2826affde0", - "reference": "8429c78ca35a09f27565311b98101e2826affde0", - "shasum": "" - }, - "require": { - "brick/math": "^0.8.16 || ^0.9 || ^0.10 || ^0.11 || ^0.12 || ^0.13 || ^0.14", - "php": "^8.0", - "ramsey/collection": "^1.2 || ^2.0" - }, - "replace": { - "rhumsaa/uuid": "self.version" - }, - "require-dev": { - "captainhook/captainhook": "^5.25", - "captainhook/plugin-composer": "^5.3", - "dealerdirect/phpcodesniffer-composer-installer": "^1.0", - "ergebnis/composer-normalize": "^2.47", - "mockery/mockery": "^1.6", - "paragonie/random-lib": "^2", - "php-mock/php-mock": "^2.6", - "php-mock/php-mock-mockery": "^1.5", - "php-parallel-lint/php-parallel-lint": "^1.4.0", - "phpbench/phpbench": "^1.2.14", - "phpstan/extension-installer": "^1.4", - "phpstan/phpstan": "^2.1", - "phpstan/phpstan-mockery": "^2.0", - "phpstan/phpstan-phpunit": "^2.0", - "phpunit/phpunit": "^9.6", - "slevomat/coding-standard": "^8.18", - "squizlabs/php_codesniffer": "^3.13" - }, - "suggest": { - "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.", - "ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.", - "ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.", - "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", - "ramsey/uuid-doctrine": "Allows the use of Ramsey\\Uuid\\Uuid as Doctrine field type." - }, - "type": "library", - "extra": { - "captainhook": { - "force-install": true - } - }, - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "Ramsey\\Uuid\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A PHP library for generating and working with universally unique identifiers (UUIDs).", - "keywords": [ - "guid", - "identifier", - "uuid" - ], - "support": { - "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.9.2" - }, - "time": "2025-12-14T04:43:48+00:00" - }, { "name": "slim/http", "version": "1.4.0", diff --git a/helpers/SlimBladeView.php b/helpers/SlimBladeView.php new file mode 100644 index 00000000..88bff646 --- /dev/null +++ b/helpers/SlimBladeView.php @@ -0,0 +1,34 @@ +ViewPaths = $viewPaths; + $this->CachePath = $cachePath; + } + + protected $ViewPaths; + protected $CachePath; + protected $ViewData = []; + + public function render(ResponseInterface $response, string $template, array $data = []) + { + $data = array_merge($this->ViewData, $data); + $renderer = new Blade($this->ViewPaths, $this->CachePath, null); + $output = $renderer->make($template, $data)->render(); + + $response->getBody()->write($output); + return $response; + } + + public function set(string $key, mixed $value) + { + $this->ViewData[$key] = $value; + } +}