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
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
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
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.
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"
}
}
diff --git a/controllers/SiteController.php b/controllers/SiteController.php
index bb4ee04..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());
@@ -85,4 +88,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/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8f1a64c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,29 @@ +version: "3.7" + +services: + app: + build: ./docker + image: thecodeholic/php_mvc + ports: + - "8080:80" + volumes: + # Mount source-code for development + - ./:/var/www + extra_hosts: + - host.docker.internal:host-gateway + + db: + image: mysql:8 + 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 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 @@ +