├── .gitignore ├── .env.example ├── .docker ├── php │ └── Dockerfile ├── mysql │ └── my.cnf └── nginx │ └── conf.d │ └── php.conf ├── LICENSE ├── docker-compose.yml ├── src └── index.php └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .env -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | COMPOSE_PROJECT_NAME=demo 2 | -------------------------------------------------------------------------------- /.docker/php/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.1-fpm 2 | 3 | RUN docker-php-ext-install pdo_mysql -------------------------------------------------------------------------------- /.docker/mysql/my.cnf: -------------------------------------------------------------------------------- 1 | [mysqld] 2 | collation-server = utf8mb4_unicode_ci 3 | character-set-server = utf8mb4 4 | -------------------------------------------------------------------------------- /.docker/nginx/conf.d/php.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | listen [::]:80; 4 | server_name php.test; 5 | root /var/www/php; 6 | index index.php; 7 | 8 | location ~* \.php$ { 9 | fastcgi_pass php:9000; 10 | include fastcgi_params; 11 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 12 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020 Yannick Chenot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | 3 | # Services 4 | services: 5 | 6 | # Nginx Service 7 | nginx: 8 | image: nginx:1.21 9 | ports: 10 | - 80:80 11 | volumes: 12 | - ./src:/var/www/php 13 | - ./.docker/nginx/conf.d:/etc/nginx/conf.d 14 | depends_on: 15 | - php 16 | 17 | # PHP Service 18 | php: 19 | build: ./.docker/php 20 | working_dir: /var/www/php 21 | volumes: 22 | - ./src:/var/www/php 23 | depends_on: 24 | mysql: 25 | condition: service_healthy 26 | 27 | # MySQL Service 28 | mysql: 29 | image: mysql/mysql-server:8.0 30 | environment: 31 | MYSQL_ROOT_PASSWORD: root 32 | MYSQL_ROOT_HOST: "%" 33 | MYSQL_DATABASE: demo 34 | volumes: 35 | - ./.docker/mysql/my.cnf:/etc/mysql/my.cnf 36 | - mysqldata:/var/lib/mysql 37 | healthcheck: 38 | test: mysqladmin ping -h 127.0.0.1 -u root --password=$$MYSQL_ROOT_PASSWORD 39 | interval: 5s 40 | retries: 10 41 | 42 | # PhpMyAdmin Service 43 | phpmyadmin: 44 | image: phpmyadmin/phpmyadmin:5 45 | ports: 46 | - 8080:80 47 | environment: 48 | PMA_HOST: mysql 49 | depends_on: 50 | mysql: 51 | condition: service_healthy 52 | 53 | # Volumes 54 | volumes: 55 | 56 | mysqldata: 57 | -------------------------------------------------------------------------------- /src/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
22 | query("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'demo'");
25 | $tables = $query->fetchAll(PDO::FETCH_COLUMN);
26 |
27 | if (empty($tables)) {
28 | echo 'There are no tables in database demo.
Database demo contains the following tables: