From 1f88696694bd2416c9edba1a227928fc38bdb0a8 Mon Sep 17 00:00:00 2001 From: TheCodeholic Date: Mon, 5 Jul 2021 14:57:50 +0400 Subject: [PATCH 01/23] Add code how to run migrations in README --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index de6bb5c..b94f515 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,13 @@ Minimalistic custom framework created for educational purposes. ## Installation 1. Download the archive or clone the project using git -1. Create `.env` file from `.env.example` file and adjust database parameters -1. Run `composer install` -1. Go to the `public` folder -1. Start php server by running command `php -S 127.0.0.1:8080` -1. Open in browser http://127.0.0.1:8080 +2. Create database schema +3. Create `.env` file from `.env.example` file and adjust database parameters (including schema name) +4. Run `composer install` +5. Run migrations by executing `php migrations.php` from the project root directory +6. Go to the `public` folder +7. Start php server by running command `php -S 127.0.0.1:8080` +8. Open in browser http://127.0.0.1:8080 > The project was created along with Youtube Video Series "[Build PHP MVC Framework](https://www.youtube.com/playlist?list=PLLQuc_7jk__Uk_QnJMPndbdKECcTEwTA1)". From 5bd7e5dc8fdbfe165568ca83ecaa19a90a28678a Mon Sep 17 00:00:00 2001 From: TheCodeholic Date: Wed, 20 Oct 2021 15:13:51 +0400 Subject: [PATCH 02/23] Add core package link --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b94f515..d2d3bc2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # PHP MVC framework Minimalistic custom framework created for educational purposes. -## NOT READY FOR PRODUCTION + + +## The framework is not well tested on production. If you use it on production you use it on your own risk. +**Related core package**: https://github.com/thecodeholic/tc-php-mvc-core ---- ## Installation From 88d0c83bc59813c846a5b3f1d4017edf988f559b Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Mon, 24 Jan 2022 10:14:55 +0400 Subject: [PATCH 03/23] Start Working on docker integration --- docker-compose.yml | 10 ++++++++++ docker/000-default.conf | 10 ++++++++++ docker/Dockerfile | 15 +++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 docker-compose.yml create mode 100644 docker/000-default.conf create mode 100644 docker/Dockerfile diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..44c665e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: "3.7" + +services: + app: + build: docker + ports: + - "80:80" + volumes: + # Mount source-code for development + - ./:/var/www diff --git a/docker/000-default.conf b/docker/000-default.conf new file mode 100644 index 0000000..3b74b4b --- /dev/null +++ b/docker/000-default.conf @@ -0,0 +1,10 @@ + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/public + + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + + \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..51d5243 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,15 @@ +FROM php:8.1-apache + +# Copy virtual host into container +COPY 000-default.conf /etc/apache2/sites-available/000-default.conf + +# Enable rewrite mode +RUN a2enmod rewrite + +WORKDIR /var/www + +# Change the owner of the container document root +RUN chown -R www-data:www-data /var/www + +CMD ["apache2-foreground"] + From 1e130105d5877a06946ec64ae566ef0a9d469e0f Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Tue, 25 Jan 2022 10:04:13 +0400 Subject: [PATCH 04/23] Create Dockerfile --- docker/Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 51d5243..856f8eb 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,6 +6,20 @@ COPY 000-default.conf /etc/apache2/sites-available/000-default.conf # Enable rewrite mode RUN a2enmod rewrite +# Install git +RUN apt-get update +RUN apt-get install libzip-dev git unzip -y --no-install-recommends + +# RUN docker-php-ext-install zip intl mbstring pdo_mysql exif gd +RUN docker-php-ext-install zip pdo_mysql + +# Install composer +RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +RUN php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" +RUN php composer-setup.php +RUN php -r "unlink('composer-setup.php');" +RUN mv composer.phar /usr/local/bin/composer + WORKDIR /var/www # Change the owner of the container document root From e8d85a11b20ca23d5e706461271534e324d2c5a2 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Sat, 29 Jan 2022 09:27:39 +0400 Subject: [PATCH 05/23] Give default value to user table status column in migration --- migrations/m0001_initial.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/m0001_initial.php b/migrations/m0001_initial.php index af841cb..b13ff22 100644 --- a/migrations/m0001_initial.php +++ b/migrations/m0001_initial.php @@ -14,7 +14,7 @@ public function up() email VARCHAR(255) NOT NULL, firstname VARCHAR(255) NOT NULL, lastname VARCHAR(255) NOT NULL, - status TINYINT NOT NULL, + status TINYINT DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ) ENGINE=INNODB;"; $db->pdo->exec($SQL); From f6ca85806dd744f6420f1abbcf5a855b54c65356 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Sat, 29 Jan 2022 09:27:58 +0400 Subject: [PATCH 06/23] Add .htaccess in public folder --- public/.htaccess | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 public/.htaccess diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..136a0e5 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,4 @@ +RewriteEngine On +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule . index.php \ No newline at end of file From 6bde7c8919cf17107c1f580530564efd39a1f76f Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Sat, 29 Jan 2022 09:28:38 +0400 Subject: [PATCH 07/23] Comment outputting text on application before request event --- public/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/index.php b/public/index.php index 7557b49..33d2be1 100644 --- a/public/index.php +++ b/public/index.php @@ -25,7 +25,7 @@ $app = new Application(dirname(__DIR__), $config); $app->on(Application::EVENT_BEFORE_REQUEST, function(){ - echo "Before request from second installation"; + // echo "Before request from second installation"; }); $app->router->get('/', [SiteController::class, 'home']); From cee1f78c9500bf010ce1765f80593b61980b3f6c Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Wed, 2 Feb 2022 07:53:10 +0400 Subject: [PATCH 08/23] Add Dockerfile and docker-compose.yml --- docker-compose.yml | 12 +++++++++++- docker/Dockerfile | 14 +++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 44c665e..6661f9e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,9 +2,19 @@ version: "3.7" services: app: - build: docker + build: ./docker + image: thecodeholic/php_mvc ports: - "80:80" volumes: # Mount source-code for development - ./:/var/www + db: + image: mysql:8 + ports: + - "3307:3306" + environment: + MYSQL_DATABASE: php_mvc + MYSQL_ROOT_PASSWORD: root + MYSQL_USER: php_mvc + MYSQL_PASSWORD: php_mvc diff --git a/docker/Dockerfile b/docker/Dockerfile index 856f8eb..bf475ed 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,11 +6,15 @@ COPY 000-default.conf /etc/apache2/sites-available/000-default.conf # Enable rewrite mode RUN a2enmod rewrite -# Install git -RUN apt-get update -RUN apt-get install libzip-dev git unzip -y --no-install-recommends - -# RUN docker-php-ext-install zip intl mbstring pdo_mysql exif gd +# Install necessary packages +RUN apt-get update && \ + apt-get install \ + libzip-dev \ + git \ + unzip \ + -y --no-install-recommends + +# Install PHP Extensions RUN docker-php-ext-install zip pdo_mysql # Install composer From fd65d8b55b871aec6db687fda9b831c15a2a9924 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Wed, 2 Feb 2022 08:08:05 +0400 Subject: [PATCH 09/23] Adjust parameters in .env.example for docker setup --- .env.example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 512046a..dee47ba 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,3 @@ -DB_DSN = mysql:host=localhost;port=3306;dbname=mvc_framework -DB_USER = root -DB_PASSWORD = \ No newline at end of file +DB_DSN = mysql:host=db;port=3306;dbname=php_mvc +DB_USER = php_mvc +DB_PASSWORD = php_mvc \ No newline at end of file From 57a86798a004ad21455e76c3e261418f7cc6e6e7 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Wed, 2 Feb 2022 08:15:02 +0400 Subject: [PATCH 10/23] Update apache outer port in docker-compose.yml --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6661f9e..a74be14 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: build: ./docker image: thecodeholic/php_mvc ports: - - "80:80" + - "8080:80" volumes: # Mount source-code for development - ./:/var/www From b2404fd0f895c793bf2b5fa0240bdf39f7ae02d4 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Wed, 2 Feb 2022 08:15:20 +0400 Subject: [PATCH 11/23] Add docker installation section in README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index d2d3bc2..3c025b9 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,17 @@ Minimalistic custom framework created for educational purposes. 7. Start php server by running command `php -S 127.0.0.1:8080` 8. Open in browser http://127.0.0.1:8080 +------ +## Installation using docker +Make sure you have docker installed. To see how you can install docker on Windows [click here](https://youtu.be/2ezNqqaSjq8).
+Make sure `docker` and `docker-compose` commands are available in command line. + +1. Clone the project using git +1. Copy `.env.example` into `.env` (Don't need to change anything for local development) +1. Navigate to the project root directory and run `docker-compose up -d` +1. Install dependencies - `docker-compose exec app composer install` +1. Run migrations - `docker-compose exec app php migrations.php` +8. Open in browser http://127.0.0.1:8080 > The project was created along with Youtube Video Series "[Build PHP MVC Framework](https://www.youtube.com/playlist?list=PLLQuc_7jk__Uk_QnJMPndbdKECcTEwTA1)". > I appreaciate if you share it. From 76d0776bdfab5e4eb95e2ae995560af663aba051 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Wed, 2 Feb 2022 09:24:22 +0400 Subject: [PATCH 12/23] Add php.ini, mysql-config and install-composer files --- docker/Dockerfile | 24 ++++++++++++++++++------ docker/install-composer.sh | 18 ++++++++++++++++++ docker/mysql-config.conf | 11 +++++++++++ docker/php.ini | 3 +++ 4 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 docker/install-composer.sh create mode 100644 docker/mysql-config.conf create mode 100644 docker/php.ini diff --git a/docker/Dockerfile b/docker/Dockerfile index bf475ed..7aa489d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -10,6 +10,7 @@ RUN a2enmod rewrite RUN apt-get update && \ apt-get install \ libzip-dev \ + wget \ git \ unzip \ -y --no-install-recommends @@ -17,13 +18,24 @@ RUN apt-get update && \ # Install PHP Extensions RUN docker-php-ext-install zip pdo_mysql -# Install composer -RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" -RUN php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" -RUN php composer-setup.php -RUN php -r "unlink('composer-setup.php');" -RUN mv composer.phar /usr/local/bin/composer +# RUN pecl install -o -f xdebug-3.1.3 \ +# && rm -rf /tmp/pear +# Copy composer +COPY ./install-composer.sh ./ + +# Copy php.ini +COPY ./php.ini /usr/local/etc/php/ + +# Cleanup packages and install composer +RUN apt-get purge -y g++ \ + && apt-get autoremove -y \ + && rm -r /var/lib/apt/lists/* \ + && rm -rf /tmp/* \ + && sh ./install-composer.sh \ + && rm ./install-composer.sh + +# Change the current working directory WORKDIR /var/www # Change the owner of the container document root diff --git a/docker/install-composer.sh b/docker/install-composer.sh new file mode 100644 index 0000000..b132791 --- /dev/null +++ b/docker/install-composer.sh @@ -0,0 +1,18 @@ +#!/bin/sh + + +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") +EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) + +if [ "$EXPECTED_SIGNATURE" != "$SIGNATURE" ] +then + echo 'ERROR: Invalid installer signature' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --quiet --install-dir=/usr/local/bin --filename=composer +RESULT=$? +rm composer-setup.php +exit $RESULT \ No newline at end of file diff --git a/docker/mysql-config.conf b/docker/mysql-config.conf new file mode 100644 index 0000000..1f3bb11 --- /dev/null +++ b/docker/mysql-config.conf @@ -0,0 +1,11 @@ +[client] +default-character-set = utf8mb4 + +[mysql] +default-character-set = utf8mb4 + +[mysqld] +init-connect='SET NAMES utf8mb4' +collation_server=utf8mb4_unicode_ci +character_set_server=utf8mb4 +default_authentication_plugin= mysql_native_password \ No newline at end of file diff --git a/docker/php.ini b/docker/php.ini new file mode 100644 index 0000000..c6d1b76 --- /dev/null +++ b/docker/php.ini @@ -0,0 +1,3 @@ +; General +upload_max_filesize = 200M +post_max_size = 220M From 871ed1bf39a4b0b391eda61f360271c05cfc686b Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Wed, 2 Feb 2022 09:30:12 +0400 Subject: [PATCH 13/23] Use mysql-config.cnf in docker-compose.yml --- docker-compose.yml | 4 +++- docker/{mysql-config.conf => mysql-config.cnf} | 0 2 files changed, 3 insertions(+), 1 deletion(-) rename docker/{mysql-config.conf => mysql-config.cnf} (100%) diff --git a/docker-compose.yml b/docker-compose.yml index a74be14..85b5915 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,8 +13,10 @@ services: image: mysql:8 ports: - "3307:3306" + volumes: + - ./docker/mysql-config.cnf:/etc/mysql/conf.d/config.cnf environment: - MYSQL_DATABASE: php_mvc MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: php_mvc MYSQL_USER: php_mvc MYSQL_PASSWORD: php_mvc diff --git a/docker/mysql-config.conf b/docker/mysql-config.cnf similarity index 100% rename from docker/mysql-config.conf rename to docker/mysql-config.cnf From 02fb3b30a35b7f1bd4af57858d2b5a9ce49014f4 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Wed, 2 Feb 2022 09:31:30 +0400 Subject: [PATCH 14/23] Add .dockerignore --- .dockerignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..68aac31 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git +runtime \ No newline at end of file From 950569922743287d07e92cb1fe8883deefa3594a Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Thu, 3 Feb 2022 08:52:02 +0400 Subject: [PATCH 15/23] Add volume to persist mysql data --- docker-compose.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 85b5915..8531289 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,9 +14,13 @@ services: ports: - "3307:3306" volumes: + - mysql-data:/var/lib/mysql - ./docker/mysql-config.cnf:/etc/mysql/conf.d/config.cnf environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: php_mvc MYSQL_USER: php_mvc MYSQL_PASSWORD: php_mvc + +volumes: + mysql-data: \ No newline at end of file From 7f1c73828035e05d671ef20a7630a73ccdcb7a3c Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Thu, 3 Feb 2022 08:59:58 +0400 Subject: [PATCH 16/23] Add .editorconfig file --- .editorconfig | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4269159 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +end_of_line = lf \ No newline at end of file From abd6d220db080dc57efaf73f8f0170407d1878d2 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Thu, 3 Feb 2022 09:00:28 +0400 Subject: [PATCH 17/23] Update .editorconfig file --- .editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/.editorconfig b/.editorconfig index 4269159..d34f47a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,4 +4,5 @@ root = true charset = utf-8 indent_style = space indent_size = 4 +tab_width = 4 end_of_line = lf \ No newline at end of file From 7a1b8fdf0864957b067d505bc40fac656bf72527 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Fri, 11 Feb 2022 08:25:00 +0400 Subject: [PATCH 18/23] Add comments in Dockerfile --- docker/Dockerfile | 3 ++- docker/install-composer.sh | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 7aa489d..9740c1d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -21,7 +21,7 @@ RUN docker-php-ext-install zip pdo_mysql # RUN pecl install -o -f xdebug-3.1.3 \ # && rm -rf /tmp/pear -# Copy composer +# Copy composer installable COPY ./install-composer.sh ./ # Copy php.ini @@ -41,5 +41,6 @@ WORKDIR /var/www # Change the owner of the container document root RUN chown -R www-data:www-data /var/www +# Start Apache in foreground CMD ["apache2-foreground"] diff --git a/docker/install-composer.sh b/docker/install-composer.sh index b132791..bcb1e7a 100644 --- a/docker/install-composer.sh +++ b/docker/install-composer.sh @@ -1,6 +1,5 @@ #!/bin/sh - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" SIGNATURE=$(php -r "echo hash_file('SHA384', 'composer-setup.php');") EXPECTED_SIGNATURE=$(wget -q -O - https://composer.github.io/installer.sig) From fc66f9258599c285a4623b71685732e630dff121 Mon Sep 17 00:00:00 2001 From: Zura Sekhniashvili Date: Mon, 21 Feb 2022 10:19:08 +0400 Subject: [PATCH 19/23] 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 20/23] 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 21/23] 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 22/23] 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 23/23] 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