From 26babb2187fb5fbd02185eb1bb367e207f589692 Mon Sep 17 00:00:00 2001 From: vastevenson <35041906+vastevenson@users.noreply.github.com> Date: Fri, 9 Sep 2022 15:32:37 -0700 Subject: [PATCH 1/4] Create README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4fce27b --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +See https://youtu.be/2Bxh5FNGznQ for a full walk through on spinning up this full-stack Php web app with MySql and phpMySql + +Requirements: +* Docker From 85403285714da56ab548ebdd8c963dd065832075 Mon Sep 17 00:00:00 2001 From: vastevenson <35041906+vastevenson@users.noreply.github.com> Date: Fri, 9 Sep 2022 15:33:15 -0700 Subject: [PATCH 2/4] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4fce27b..7e7ee70 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,5 @@ See https://youtu.be/2Bxh5FNGznQ for a full walk through on spinning up this ful Requirements: * Docker + +To run this code, run command: `docker-compose up` from the shell within the directory of this project after cloning it. From 82f2e6ace85732060e43d37742e6db52dcf03ef6 Mon Sep 17 00:00:00 2001 From: vastevenson <35041906+vastevenson@users.noreply.github.com> Date: Sat, 10 Sep 2022 10:53:02 -0700 Subject: [PATCH 3/4] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 7e7ee70..a319798 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,7 @@ Requirements: * Docker To run this code, run command: `docker-compose up` from the shell within the directory of this project after cloning it. + +If you get the error: `Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 3` + +Open the interactive terminal with your docker container that's running the `www` service and run the command: `docker-php-ext-install mysqli && docker-php-ext-enable mysqli && apachectl restart` From 254911062c3caf594f47c230f78530e5beb0bfcc Mon Sep 17 00:00:00 2001 From: Joshua Scott <2485451+joshuaascott@users.noreply.github.com> Date: Wed, 19 Oct 2022 02:26:06 -0400 Subject: [PATCH 4/4] Removes possible error with mysqli dependency * Moves the src files to a central location 'src/' * Creates a Dockerfile to initiate the install of mysqli * Adds container names to associated images --- Dockerfile | 6 ++++++ README.md | 11 ++++++----- docker-compose.yml | 13 +++++++++---- index.php => src/index.php | 0 test.php => src/test.php | 0 5 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 Dockerfile rename index.php => src/index.php (100%) rename test.php => src/test.php (100%) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bc9fb4b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM php:8-apache + +RUN docker-php-ext-install mysqli + +EXPOSE 80/tcp +EXPOSE 443/tcp diff --git a/README.md b/README.md index a319798..ea56cb0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ +# PHP Docker Full Stack + See https://youtu.be/2Bxh5FNGznQ for a full walk through on spinning up this full-stack Php web app with MySql and phpMySql -Requirements: -* Docker +## Requirements: -To run this code, run command: `docker-compose up` from the shell within the directory of this project after cloning it. +* Docker -If you get the error: `Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 3` +## Getting Started -Open the interactive terminal with your docker container that's running the `www` service and run the command: `docker-php-ext-install mysqli && docker-php-ext-enable mysqli && apachectl restart` +To run this code, run command: `docker-compose up` from the shell within the directory of this project after cloning it. diff --git a/docker-compose.yml b/docker-compose.yml index 95b4dcf..159cdd2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ version: '3' services: - db: + db: + container_name: mysql image: mysql:latest environment: - MYSQL_DATABASE=php_docker @@ -10,16 +11,20 @@ services: volumes: - "./db:/docker-entrypoint-initdb.d" # this is how we persist a sql db even when container stops www: - image: php:apache + container_name: php + build: + context: . + dockerfile: Dockerfile volumes: - - "./:/var/www/html" # sync the current dir on local machine to the dir of container + - "./src:/var/www/html" # sync the current dir on local machine to the dir of container ports: - 80:80 - 443:443 # for future ssl traffic phpmyadmin: + container_name: phpmyadmin image: phpmyadmin/phpmyadmin ports: - 8001:80 environment: - PMA_HOST=db - - PMA_PORT=3306 \ No newline at end of file + - PMA_PORT=3306 diff --git a/index.php b/src/index.php similarity index 100% rename from index.php rename to src/index.php diff --git a/test.php b/src/test.php similarity index 100% rename from test.php rename to src/test.php