From 394b8d890c39f61de7489bbd45c3be64ef5b6c4a Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 22 Mar 2026 10:51:22 +0200 Subject: [PATCH 1/9] move response logic to new view controller --- app/View/ViewController.php | 14 ++++++++++++++ bootstrap/app.php | 7 ++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 app/View/ViewController.php diff --git a/app/View/ViewController.php b/app/View/ViewController.php new file mode 100644 index 0000000..a41ac7e --- /dev/null +++ b/app/View/ViewController.php @@ -0,0 +1,14 @@ +render($response, 'admin.html.twig', []); + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index ab6b076..5bbbb40 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -5,6 +5,7 @@ use Psr\Http\Message\ServerRequestInterface as Request; use DI\Bridge\Slim\Bridge; use Slim\Views\Twig; use Slim\Views\TwigMiddleware; +use App\View\ViewController; $container = require __DIR__.'/container.php'; $app = Bridge::create($container); @@ -14,10 +15,6 @@ $app->add(TwigMiddleware::create($app, $container->get(Twig::class))); // change first param to false for production $app->addErrorMiddleware(true, true, true); -$app->get('/admin', function (Response $response, Twig $twig) { - return $twig->render($response, 'admin.html.twig', [ - 'name' => 'John', - ]); -}); +$app->get('/admin', [ViewController::class, 'admin']); return $app; From d66277b824602b511030b377f4102e0de5e03a9d Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sun, 22 Mar 2026 10:52:33 +0200 Subject: [PATCH 2/9] rename home file to admin --- cypress/e2e/{home.cy.js => admin.cy.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cypress/e2e/{home.cy.js => admin.cy.js} (100%) diff --git a/cypress/e2e/home.cy.js b/cypress/e2e/admin.cy.js similarity index 100% rename from cypress/e2e/home.cy.js rename to cypress/e2e/admin.cy.js From 6d75d3770a621468e6c4de0f5c1a6ad758fab434 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 11 Apr 2026 22:36:30 +0300 Subject: [PATCH 3/9] use regular php files instead of twig --- app/View/ViewController.php | 5 ++++- views/templates/admin.php | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 views/templates/admin.php diff --git a/app/View/ViewController.php b/app/View/ViewController.php index a41ac7e..7b65514 100644 --- a/app/View/ViewController.php +++ b/app/View/ViewController.php @@ -9,6 +9,9 @@ class ViewController { public function admin(Response $response, Twig $view): Response { - return $view->render($response, 'admin.html.twig', []); + $html = file_get_contents(__DIR__.'/../../views/templates/admin.php', true); + $response->getBody()->write($html); + + return $response; } } diff --git a/views/templates/admin.php b/views/templates/admin.php new file mode 100644 index 0000000..c027843 --- /dev/null +++ b/views/templates/admin.php @@ -0,0 +1,10 @@ + + + + Daily Goals + + + + + + From 5fba2138e2776abff3597ec5eca0362e900eaa89 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 11 Apr 2026 22:37:14 +0300 Subject: [PATCH 4/9] assert input and button for adding texts exists --- cypress/e2e/admin.cy.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/admin.cy.js b/cypress/e2e/admin.cy.js index af905a6..c277eb9 100644 --- a/cypress/e2e/admin.cy.js +++ b/cypress/e2e/admin.cy.js @@ -1,6 +1,7 @@ describe('The admin page', () => { it('successfully loads texts', () => { cy.visit('/admin') - + cy.get('#newTextname').type('new text') + cy.get('#submit').click() }) }) From 6b4ea8a1f4970087e96a7d00dfc163c8f745856d Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 11 Apr 2026 22:41:30 +0300 Subject: [PATCH 5/9] remove all twig related code --- app/View/ViewController.php | 3 +- bootstrap/app.php | 4 - bootstrap/container.php | 6 +- composer.json | 3 +- composer.lock | 462 +------------------------------- views/templates/admin.html.twig | 9 - 6 files changed, 4 insertions(+), 483 deletions(-) delete mode 100644 views/templates/admin.html.twig diff --git a/app/View/ViewController.php b/app/View/ViewController.php index 7b65514..fb46073 100644 --- a/app/View/ViewController.php +++ b/app/View/ViewController.php @@ -3,11 +3,10 @@ namespace App\View; use Psr\Http\Message\ResponseInterface as Response; -use Slim\Views\Twig; class ViewController { - public function admin(Response $response, Twig $view): Response + public function admin(Response $response): Response { $html = file_get_contents(__DIR__.'/../../views/templates/admin.php', true); $response->getBody()->write($html); diff --git a/bootstrap/app.php b/bootstrap/app.php index 5bbbb40..1fc3b7e 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -3,15 +3,11 @@ use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use DI\Bridge\Slim\Bridge; -use Slim\Views\Twig; -use Slim\Views\TwigMiddleware; use App\View\ViewController; $container = require __DIR__.'/container.php'; $app = Bridge::create($container); -$app->add(TwigMiddleware::create($app, $container->get(Twig::class))); - // change first param to false for production $app->addErrorMiddleware(true, true, true); diff --git a/bootstrap/container.php b/bootstrap/container.php index a2e05f1..3a35c97 100644 --- a/bootstrap/container.php +++ b/bootstrap/container.php @@ -1,13 +1,9 @@ Twig::create(__DIR__.'/../views/templates', ['cache' => false]), + ]); return $container; diff --git a/composer.json b/composer.json index fc70c5c..b616d04 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ "require": { "slim/slim": "4.*", "slim/psr7": "^1.8", - "php-di/slim-bridge": "^3.4", - "slim/twig-view": "^3.4" + "php-di/slim-bridge": "^3.4" } } diff --git a/composer.lock b/composer.lock index ad61349..cb8d8f4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "97037d1273acea26944186b448ec1e66", + "content-hash": "705af1d0dbc909c90c5b025f3f594a49", "packages": [ { "name": "fig/http-message-util", @@ -905,466 +905,6 @@ } ], "time": "2025-11-21T12:23:44+00:00" - }, - { - "name": "slim/twig-view", - "version": "3.4.1", - "source": { - "type": "git", - "url": "https://github.com/slimphp/Twig-View.git", - "reference": "b4268d87d0e327feba5f88d32031e9123655b909" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/slimphp/Twig-View/zipball/b4268d87d0e327feba5f88d32031e9123655b909", - "reference": "b4268d87d0e327feba5f88d32031e9123655b909", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0", - "psr/http-message": "^1.1 || ^2.0", - "slim/slim": "^4.12", - "symfony/polyfill-php81": "^1.29", - "twig/twig": "^3.11" - }, - "require-dev": { - "phpspec/prophecy-phpunit": "^2.0", - "phpstan/phpstan": "^1.10.59", - "phpunit/phpunit": "^9.6 || ^10", - "psr/http-factory": "^1.0", - "squizlabs/php_codesniffer": "^3.9" - }, - "type": "library", - "autoload": { - "psr-4": { - "Slim\\Views\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Josh Lockhart", - "email": "hello@joshlockhart.com", - "homepage": "http://joshlockhart.com" - }, - { - "name": "Pierre Berube", - "email": "pierre@lgse.com", - "homepage": "http://www.lgse.com" - } - ], - "description": "Slim Framework 4 view helper built on top of the Twig 3 templating component", - "homepage": "https://www.slimframework.com", - "keywords": [ - "framework", - "slim", - "template", - "twig", - "view" - ], - "support": { - "issues": "https://github.com/slimphp/Twig-View/issues", - "source": "https://github.com/slimphp/Twig-View/tree/3.4.1" - }, - "time": "2024-09-26T05:42:02+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v3.6.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", - "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/contracts", - "name": "symfony/contracts" - }, - "branch-alias": { - "dev-main": "3.6-dev" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-25T14:21:43+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.33.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", - "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "provide": { - "ext-ctype": "*" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.33.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493", - "reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493", - "shasum": "" - }, - "require": { - "ext-iconv": "*", - "php": ">=7.2" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-12-23T08:48:59+00:00" - }, - { - "name": "symfony/polyfill-php81", - "version": "v1.33.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", - "shasum": "" - }, - "require": { - "php": ">=7.2" - }, - "type": "library", - "extra": { - "thanks": { - "url": "https://github.com/symfony/polyfill", - "name": "symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php81\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.33.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://github.com/nicolas-grekas", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-09-09T11:45:10+00:00" - }, - { - "name": "twig/twig", - "version": "v3.24.0", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "a6769aefb305efef849dc25c9fd1653358c148f0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/a6769aefb305efef849dc25c9fd1653358c148f0", - "reference": "a6769aefb305efef849dc25c9fd1653358c148f0", - "shasum": "" - }, - "require": { - "php": ">=8.1.0", - "symfony/deprecation-contracts": "^2.5|^3", - "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3" - }, - "require-dev": { - "php-cs-fixer/shim": "^3.0@stable", - "phpstan/phpstan": "^2.0@stable", - "psr/container": "^1.0|^2.0", - "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0" - }, - "type": "library", - "autoload": { - "files": [ - "src/Resources/core.php", - "src/Resources/debug.php", - "src/Resources/escaper.php", - "src/Resources/string_loader.php" - ], - "psr-4": { - "Twig\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Twig Team", - "role": "Contributors" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "https://twig.symfony.com", - "keywords": [ - "templating" - ], - "support": { - "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.24.0" - }, - "funding": [ - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/twig/twig", - "type": "tidelift" - } - ], - "time": "2026-03-17T21:31:11+00:00" } ], "packages-dev": [ diff --git a/views/templates/admin.html.twig b/views/templates/admin.html.twig deleted file mode 100644 index 4470db1..0000000 --- a/views/templates/admin.html.twig +++ /dev/null @@ -1,9 +0,0 @@ - - - - Daily Goals - - -

- - From b10a057ab8d20c72ff8b3ac19f0a88798a31ff3a Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 11 Apr 2026 22:55:27 +0300 Subject: [PATCH 6/9] init flake with dev shell for node and cypress --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 19 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..8ec14d2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1775710090, + "narHash": "sha256-ar3rofg+awPB8QXDaFJhJ2jJhu+KqN/PRCXeyuXR76E=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4c1018dae018162ec878d42fec712642d214fdfa", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..061f3f8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,19 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = { self, nixpkgs }: + let + system = "x86_64-linux"; + in { + devShells."${system}".default = let + pkgs = import nixpkgs { inherit system; }; + in pkgs.mkShell { + buildInputs = with pkgs; [ + nodejs_25 + cypress + ]; + }; + }; +} From 6f5688b12cce08c32e87ef9c164bedb213973fcb Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 11 Apr 2026 22:57:08 +0300 Subject: [PATCH 7/9] add php 8.5 to flake --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 061f3f8..6beeb2d 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,7 @@ buildInputs = with pkgs; [ nodejs_25 cypress + php85 ]; }; }; From c2a1d5595ea868dfa7139493cab21fd3a4b3daa9 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 11 Apr 2026 23:02:23 +0300 Subject: [PATCH 8/9] change buildInputs to packages --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 6beeb2d..2f6b6f3 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ devShells."${system}".default = let pkgs = import nixpkgs { inherit system; }; in pkgs.mkShell { - buildInputs = with pkgs; [ + packages = with pkgs; [ nodejs_25 cypress php85 From 5d2b847a54f05ed17982862d2d10e2190df013d6 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Sat, 11 Apr 2026 23:06:26 +0300 Subject: [PATCH 9/9] declare pkgs according to different convention --- flake.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index 2f6b6f3..8c2fffd 100644 --- a/flake.nix +++ b/flake.nix @@ -6,10 +6,9 @@ outputs = { self, nixpkgs }: let system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; in { - devShells."${system}".default = let - pkgs = import nixpkgs { inherit system; }; - in pkgs.mkShell { + devShells."${system}".default = pkgs.mkShell { packages = with pkgs; [ nodejs_25 cypress