From e8724e23c98026cf3451a9fdad90da7ec347f2ce Mon Sep 17 00:00:00 2001 From: designcise Date: Sat, 1 Jul 2023 01:27:31 +0200 Subject: [PATCH 01/10] feat: updated PHP version to 8.2 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3b971be..12c6832 100755 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN composer install \ --optimize-autoloader \ --prefer-dist -FROM php:8.1.1-fpm AS base +FROM php:8.2-fpm AS base COPY --from=vendor /usr/bin/composer /usr/bin/composer RUN apt-get update \ From d61b16cb357e5091488bd8bd1711eafb9c5c81b6 Mon Sep 17 00:00:00 2001 From: designcise Date: Sat, 1 Jul 2023 01:28:37 +0200 Subject: [PATCH 02/10] chore: updated composer dependencies --- www/composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/www/composer.json b/www/composer.json index baac0ea..ebc8888 100755 --- a/www/composer.json +++ b/www/composer.json @@ -1,10 +1,10 @@ { "require": { - "php": ">=8.1", - "designcise/bitframe": "^3.6", - "designcise/bitframe-fastroute": "^3.6", - "designcise/bitframe-whoops": "^3.6", - "nyholm/psr7": "^1.4" + "php": ">=8.2", + "designcise/bitframe": "^4.x-dev", + "designcise/bitframe-fastroute": "^4.x-dev", + "designcise/bitframe-whoops": "^4.x-dev", + "nyholm/psr7": "^1.8.0" }, "require-dev": { "roave/security-advisories": "dev-master", From 9469e36b2864852e0678bcaae2e6ac2086656563 Mon Sep 17 00:00:00 2001 From: designcise Date: Sat, 1 Jul 2023 01:29:24 +0200 Subject: [PATCH 03/10] chore: removed composer.lock from ignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index b5dbeb2..029ea9d 100755 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ vendor .idea .DS_Store *.cache -composer.lock \ No newline at end of file From 35fa05adba93f1e0ff116e49ae017a84708d8939 Mon Sep 17 00:00:00 2001 From: designcise Date: Sat, 1 Jul 2023 01:30:19 +0200 Subject: [PATCH 04/10] refactor: added newline --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 857aa6a..a34e019 100755 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,4 @@ .gitignore LICENSE README.md -CHANGELOG.md \ No newline at end of file +CHANGELOG.md From d3d96226e88e59ed0f590bee3441b10707501de8 Mon Sep 17 00:00:00 2001 From: designcise Date: Sat, 1 Jul 2023 01:30:51 +0200 Subject: [PATCH 05/10] docs: updated copyright year --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 1c5e292..dca1a4c 100755 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # License -### Copyright (c) 2017-2022 Daniyal Hamid (https://designcise.com) +### Copyright (c) 2017-2023 Daniyal Hamid (https://designcise.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: From 6c3ed32eed8ca7edecc12cd6fca1e5a0a77f8c08 Mon Sep 17 00:00:00 2001 From: designcise Date: Sat, 1 Jul 2023 01:33:00 +0200 Subject: [PATCH 06/10] docs: updated readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 473b857..5d7f858 100755 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ Simply clone the repo and start building your projects. ### Prerequisites: -- BitFrame v3.6 -- PHP 8.1+ -- Nginx +- BitFrame v4.0 +- PHP 8.2+ +- Nginx (or Apache) - Docker Engine 1.13.0+ ## Directory Structure From 7ea37e6f8713fddc30a3350982d38a5079cee332 Mon Sep 17 00:00:00 2001 From: designcise Date: Sat, 1 Jul 2023 01:46:42 +0200 Subject: [PATCH 07/10] refactor: removed netcat package --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 12c6832..83bd882 100755 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ FROM php:8.2-fpm AS base COPY --from=vendor /usr/bin/composer /usr/bin/composer RUN apt-get update \ - && apt-get install -y --fix-missing curl git vim wget netcat chrpath git unzip zip \ + && apt-get install -y --fix-missing curl git vim wget chrpath git unzip zip \ && usermod -u 1000 www-data \ && usermod -G staff www-data \ && chown -R www-data:www-data /var/www \ From c324e424e022ba35683aacd83d2600ff8d00b3cf Mon Sep 17 00:00:00 2001 From: designcise Date: Sat, 1 Jul 2023 01:47:39 +0200 Subject: [PATCH 08/10] feat: attribute-based routing example --- www/server/app/Controller/DefaultController.php | 9 +++++++-- www/server/config/routes.php | 4 +++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/www/server/app/Controller/DefaultController.php b/www/server/app/Controller/DefaultController.php index 06f39f7..7de5b06 100755 --- a/www/server/app/Controller/DefaultController.php +++ b/www/server/app/Controller/DefaultController.php @@ -7,16 +7,21 @@ use Psr\Http\Message\{ServerRequestInterface, ResponseInterface}; use Psr\Http\Server\RequestHandlerInterface; use BitFrame\Container; +use BitFrame\FastRoute\Route; class DefaultController { + public function __construct( + private readonly Container $container, + ) {} + + #[Route(['GET'], '/hello/{action}')] public function testAction( ServerRequestInterface $request, RequestHandlerInterface $handler, - Container $container ): ResponseInterface { $response = $handler->handle($request); - $globals = $container['globals']; + $globals = $this->container['globals']; $response->getBody()->write( "{$globals['title']} - 👋 Build Something Amazing Today!" diff --git a/www/server/config/routes.php b/www/server/config/routes.php index 111fa51..5c1e1df 100755 --- a/www/server/config/routes.php +++ b/www/server/config/routes.php @@ -7,5 +7,7 @@ use YourProject\App\Controller\DefaultController; return static function (AbstractRouter $router, Container $container) { - $router->get('/hello/{action}', [DefaultController::class, 'testAction', $container]); + $router->registerControllers([ + new DefaultController($container), + ]); }; From 29188ed72f0ffe8b8318c0d83349af9b2b0e3943 Mon Sep 17 00:00:00 2001 From: designcise Date: Sat, 1 Jul 2023 01:54:56 +0200 Subject: [PATCH 09/10] feat: added example for json response --- www/server/app/Controller/DefaultController.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/www/server/app/Controller/DefaultController.php b/www/server/app/Controller/DefaultController.php index 7de5b06..114b2e8 100755 --- a/www/server/app/Controller/DefaultController.php +++ b/www/server/app/Controller/DefaultController.php @@ -8,6 +8,7 @@ use Psr\Http\Server\RequestHandlerInterface; use BitFrame\Container; use BitFrame\FastRoute\Route; +use BitFrame\Http\Message\JsonResponse; class DefaultController { @@ -16,7 +17,7 @@ public function __construct( ) {} #[Route(['GET'], '/hello/{action}')] - public function testAction( + public function indexAction( ServerRequestInterface $request, RequestHandlerInterface $handler, ): ResponseInterface { @@ -29,4 +30,17 @@ public function testAction( return $response; } + + #[Route(['GET'], '/json')] + public function jsonAction(): ResponseInterface + { + $globals = $this->container['globals']; + + return JsonResponse::create([ + 'data' => [ + 'title' => $globals['title'], + 'mainHeading' => 'Build Something Amazing Today!', + ], + ]); + } } From fbfc8dbe3d40f5c8b2bd9d1e89256a748bde7f9e Mon Sep 17 00:00:00 2001 From: designcise Date: Sun, 2 Jul 2023 01:56:23 +0200 Subject: [PATCH 10/10] chore: updated bitframe suite to v4.0 --- www/composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/composer.json b/www/composer.json index ebc8888..519d1f2 100755 --- a/www/composer.json +++ b/www/composer.json @@ -1,9 +1,9 @@ { "require": { "php": ">=8.2", - "designcise/bitframe": "^4.x-dev", - "designcise/bitframe-fastroute": "^4.x-dev", - "designcise/bitframe-whoops": "^4.x-dev", + "designcise/bitframe": "^4.0", + "designcise/bitframe-fastroute": "^4.0", + "designcise/bitframe-whoops": "^4.0", "nyholm/psr7": "^1.8.0" }, "require-dev": {