From fc66f9258599c285a4623b71685732e630dff121 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Mon, 21 Feb 2022 10:19:08 +0400 Subject: [PATCH 1/5] Working on url params --- controllers/SiteController.php | 9 ++++++++- public/index.php | 14 +++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/controllers/SiteController.php b/controllers/SiteController.php index bb4ee04..c3430bc 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -85,4 +85,11 @@ public function profile() { return $this->render('profile'); } -} \ No newline at end of file + + public function profileWithId(Request $request) + { + echo '
';
+        var_dump($request->getBody());
+        echo '
'; + } +} diff --git a/public/index.php b/public/index.php index 7557b49..b8d7a51 100644 --- a/public/index.php +++ b/public/index.php @@ -24,18 +24,26 @@ $app = new Application(dirname(__DIR__), $config); -$app->on(Application::EVENT_BEFORE_REQUEST, function(){ +/*$app->on(Application::EVENT_BEFORE_REQUEST, function(){ echo "Before request from second installation"; -}); +});*/ $app->router->get('/', [SiteController::class, 'home']); $app->router->get('/register', [SiteController::class, 'register']); $app->router->post('/register', [SiteController::class, 'register']); $app->router->get('/login', [SiteController::class, 'login']); +$app->router->get('/login/{id}', [SiteController::class, 'login']); $app->router->post('/login', [SiteController::class, 'login']); $app->router->get('/logout', [SiteController::class, 'logout']); $app->router->get('/contact', [SiteController::class, 'contact']); $app->router->get('/about', [AboutController::class, 'index']); $app->router->get('/profile', [SiteController::class, 'profile']); +// /profile/{id} +// /profile/13 +// \/profile\/\w+ -$app->run(); \ No newline at end of file +// /profile/{id}/zura +// /profile/12/zura + +// /{id} +$app->run(); From 2737906075a61d06756c1f1dae25ff8aefd6bc59 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Tue, 22 Feb 2022 10:50:59 +0400 Subject: [PATCH 2/5] Implement possibility to get route params from URL --- controllers/SiteController.php | 3 +++ public/index.php | 1 + 2 files changed, 4 insertions(+) diff --git a/controllers/SiteController.php b/controllers/SiteController.php index c3430bc..fdb79b4 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -38,6 +38,9 @@ public function home() public function login(Request $request) { + echo '
';
+        var_dump($request->getBody(), $request->getRouteParam('id'));
+        echo '
'; $loginForm = new LoginForm(); if ($request->getMethod() === 'post') { $loginForm->loadData($request->getBody()); diff --git a/public/index.php b/public/index.php index 9e281b2..8572ddf 100644 --- a/public/index.php +++ b/public/index.php @@ -38,6 +38,7 @@ $app->router->get('/contact', [SiteController::class, 'contact']); $app->router->get('/about', [AboutController::class, 'index']); $app->router->get('/profile', [SiteController::class, 'profile']); +$app->router->get('/profile/{id:\d+}/{username}', [SiteController::class, 'login']); // /profile/{id} // /profile/13 // \/profile\/\w+ From 95341ce6721153e75016e574de91d82800a54bf2 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Tue, 22 Feb 2022 11:07:13 +0400 Subject: [PATCH 3/5] Update core to version 1.0.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ff794d0..12a7b15 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,6 @@ }, "require": { "vlucas/phpdotenv": "^5.0", - "thecodeholic/php-mvc-core": "^v1.0.4" + "thecodeholic/php-mvc-core": "^v1.0.5" } } From 9f113608807516847d26a1f723471b7ec788cdf3 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Sat, 10 Sep 2022 23:45:40 +0400 Subject: [PATCH 4/5] Ignore .vscode folder --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3070064..8e5a570 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea vendor composer.lock -.env \ No newline at end of file +.env +.vscode \ No newline at end of file From 8952cce1cc759020785dfa95b3c0cf9612fb0d49 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Sat, 17 Sep 2022 15:37:21 +0400 Subject: [PATCH 5/5] Integrate xdebug with docker --- docker-compose.yml | 3 +++ docker/Dockerfile | 3 ++- docker/php.ini | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8531289..8f1a64c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,9 @@ services: volumes: # Mount source-code for development - ./:/var/www + extra_hosts: + - host.docker.internal:host-gateway + db: image: mysql:8 ports: diff --git a/docker/Dockerfile b/docker/Dockerfile index 9740c1d..afe41e5 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -18,7 +18,8 @@ RUN apt-get update && \ # Install PHP Extensions RUN docker-php-ext-install zip pdo_mysql -# RUN pecl install -o -f xdebug-3.1.3 \ +RUN pecl install -o -f xdebug-3.1.5 \ + && docker-php-ext-enable xdebug # && rm -rf /tmp/pear # Copy composer installable diff --git a/docker/php.ini b/docker/php.ini index c6d1b76..dd15c37 100644 --- a/docker/php.ini +++ b/docker/php.ini @@ -1,3 +1,8 @@ ; General upload_max_filesize = 200M post_max_size = 220M + +[xdebug] +xdebug.mode = debug +xdebug.start_with_request = yes +xdebug.client_host = host.docker.internal \ No newline at end of file