Fully functional
18
.gitignore
vendored
@@ -3,19 +3,13 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# Website
|
# Website
|
||||||
Open-RSC-Website
|
Website/Open-RSC-Website
|
||||||
|
|
||||||
# Game
|
# Game
|
||||||
Open-RSC
|
Game/
|
||||||
|
|
||||||
# Netbeans
|
|
||||||
nbproject/
|
|
||||||
/nbproject/
|
|
||||||
/nbproject/private/
|
|
||||||
/nbproject/private/private.properties
|
|
||||||
|
|
||||||
# SSL Certs
|
|
||||||
etc/ssl/
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
data
|
Website/data
|
||||||
|
|
||||||
|
# SSL Certs
|
||||||
|
Website/etc/ssl/
|
||||||
|
|||||||
30
.travis.yml
@@ -1,30 +0,0 @@
|
|||||||
sudo: required
|
|
||||||
|
|
||||||
env:
|
|
||||||
DOCKER_COMPOSE_VERSION: 1.18.0
|
|
||||||
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- sudo apt update
|
|
||||||
- sudo rm /usr/local/bin/docker-compose
|
|
||||||
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
|
|
||||||
- chmod +x docker-compose
|
|
||||||
- sudo mv docker-compose /usr/local/bin
|
|
||||||
- docker-compose --version
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- sudo make docker-start
|
|
||||||
- sleep 2m
|
|
||||||
|
|
||||||
script:
|
|
||||||
- sudo make apidoc
|
|
||||||
- sudo make gen-certs
|
|
||||||
- sudo make mysql-dump
|
|
||||||
- sudo make mysql-restore
|
|
||||||
- sudo make phpmd
|
|
||||||
- sudo make test
|
|
||||||
|
|
||||||
after_script:
|
|
||||||
- sudo make docker-stop
|
|
||||||
46
Makefile
@@ -3,23 +3,23 @@
|
|||||||
include .env
|
include .env
|
||||||
|
|
||||||
# MySQL
|
# MySQL
|
||||||
MYSQL_DUMPS_DIR=data/db/dumps
|
MYSQL_DUMPS_DIR=data/db
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "usage: make COMMAND"
|
@echo "usage: make COMMAND"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Commands:"
|
@echo "Commands:"
|
||||||
@echo " clone Clone the GitHub repos"
|
@echo " clone Clone the git repository folders"
|
||||||
@echo " pull Get the latest GitHub repo updates"
|
@echo " pull Get the latest git repository updates"
|
||||||
@echo " start Create and start containers"
|
@echo " start Create and start containers"
|
||||||
@echo " stop Stop all services"
|
@echo " stop Stop all containers"
|
||||||
@echo " restart Restart containers"
|
@echo " restart Restart all containers"
|
||||||
@echo " logs Follow log output"
|
@echo " logs Display log output"
|
||||||
@echo " import Import all databases from the GitHub repos"
|
@echo " import Import all databases from git repositories"
|
||||||
@echo " dump Create backup of all local databases"
|
@echo " backup Create backup of all local databases"
|
||||||
@echo " restore Restore backup of all local databases"
|
@echo " restore Restore backup of all local databases"
|
||||||
@echo " flush Delete local GitHub repos"
|
@echo " flush Delete local git repository folders"
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|
||||||
start: init
|
start: init
|
||||||
@@ -33,34 +33,32 @@ restart: init
|
|||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
|
||||||
clone:
|
clone:
|
||||||
@$(shell git clone https://github.com/Marwolf/Open-RSC-Website.git)
|
@$(shell cd Website && git clone https://github.com/Marwolf/Open-RSC-Website.git)
|
||||||
@$(shell git clone https://github.com/Marwolf/Open-RSC)
|
@$(shell cd Game && git clone https://github.com/Marwolf/Open-RSC-Game.git)
|
||||||
@$(shell sudo chmod -R 777 Open-RSC-Website/board/cache/ && sudo chmod 644 Open-RSC-Website/board/config.php)
|
@$(shell sudo chmod -R 777 Website/Open-RSC-Website && sudo chmod -R 777 Game/Open-RSC-Game && sudo chmod 644 Website/Open-RSC-Website/board/config.php)
|
||||||
|
|
||||||
pull:
|
pull:
|
||||||
@$(shell cd Open-RSC-Website && git pull && cd .. && cd Open-RSC && git pull && cd ..)
|
@$(shell cd Website/Open-RSC-Website && git pull)
|
||||||
|
@$(shell cd Game/Open-RSC-Game && git pull)
|
||||||
|
|
||||||
logs:
|
logs:
|
||||||
@docker-compose logs -f
|
@docker-compose logs -f
|
||||||
|
|
||||||
dump:
|
backup:
|
||||||
@mkdir -p $(MYSQL_DUMPS_DIR)
|
@mkdir -p $(MYSQL_DUMPS_DIR)
|
||||||
@docker exec $(shell docker-compose ps -q mysqldb) mysqldump --all-databases -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" > $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null
|
@docker exec $(shell docker-compose ps -q mysqldb) mysqldump --all-databases -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" > Website/$(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null
|
||||||
@make resetOwner
|
@make resetOwner
|
||||||
|
|
||||||
restore:
|
restore:
|
||||||
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < $(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null
|
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Website/$(MYSQL_DUMPS_DIR)/db.sql 2>/dev/null
|
||||||
|
|
||||||
import:
|
import:
|
||||||
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Open-RSC/Databases/openrsc_config.sql 2>/dev/null
|
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Game/Open-RSC-Game/Databases/openrsc_config.sql 2>/dev/null
|
||||||
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Open-RSC/Databases/openrsc_logs.sql 2>/dev/null
|
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Game/Open-RSC-Game/Databases/openrsc_logs.sql 2>/dev/null
|
||||||
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Open-RSC/Databases/openrsc.sql 2>/dev/null
|
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Game/Open-RSC-Game/Databases/openrsc.sql 2>/dev/null
|
||||||
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Open-RSC-Website/openrsc_forum.sql 2>/dev/null
|
@docker exec -i $(shell docker-compose ps -q mysqldb) mysql -u"$(MYSQL_ROOT_USER)" -p"$(MYSQL_ROOT_PASSWORD)" < Website/Open-RSC-Website/openrsc_forum.sql 2>/dev/null
|
||||||
|
|
||||||
flush:
|
flush:
|
||||||
@$(shell rm -rf Open-RSC-Website && rm -rf Open-RSC)
|
@$(shell rm -rf Website/Open-RSC-Website && rm -rf Game/Open-RSC-Game)
|
||||||
|
|
||||||
resetOwner:
|
|
||||||
@$(shell chown -Rf $(SUDO_USER):$(shell id -g -n $(SUDO_USER)) $(MYSQL_DUMPS_DIR) "$(shell pwd)/etc/ssl" 2> /dev/null)
|
|
||||||
|
|
||||||
.PHONY: clean test code-sniff init
|
.PHONY: clean test code-sniff init
|
||||||
|
|||||||
335
README.md
@@ -1,42 +1,16 @@
|
|||||||
# Nginx PHP MySQL [](https://travis-ci.org/nanoninja/docker-nginx-php-mysql) [](https://badge.fury.io/gh/nanoninja%2Fdocker-nginx-php-mysql)
|
|
||||||
|
|
||||||
Docker running Nginx, PHP-FPM, Composer, MySQL and PHPMyAdmin.
|
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
1. [Install prerequisites](#install-prerequisites)
|
1. [Install prerequisites](#install-prerequisites)
|
||||||
|
|
||||||
Before installing project make sure the following prerequisites have been met.
|
|
||||||
|
|
||||||
2. [Clone the project](#clone-the-project)
|
2. [Clone the project](#clone-the-project)
|
||||||
|
|
||||||
We’ll download the code from its repository on GitHub.
|
3. [Run the application](#run-the-application)
|
||||||
|
|
||||||
3. [Configure Nginx With SSL Certificates](#configure-nginx-with-ssl-certificates) [`Optional`]
|
|
||||||
|
|
||||||
We'll generate and configure SSL certificate for nginx before running server.
|
|
||||||
|
|
||||||
4. [Configure Xdebug](#configure-xdebug) [`Optional`]
|
|
||||||
|
|
||||||
We'll configure Xdebug for IDE (PHPStorm or Netbeans).
|
|
||||||
|
|
||||||
5. [Run the application](#run-the-application)
|
|
||||||
|
|
||||||
By this point we’ll have all the project pieces in place.
|
|
||||||
|
|
||||||
6. [Use Makefile](#use-makefile) [`Optional`]
|
|
||||||
|
|
||||||
When developing, you can use `Makefile` for doing recurrent operations.
|
|
||||||
|
|
||||||
7. [Use Docker Commands](#use-docker-commands)
|
|
||||||
|
|
||||||
When running, you can use docker commands for doing recurrent operations.
|
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
## Install prerequisites
|
## Install prerequisites
|
||||||
|
|
||||||
For now, this project has been mainly created for Unix `(Linux/MacOS)`. Perhaps it could work on Windows.
|
This project has been created for `(Linux/MacOS)`.
|
||||||
|
|
||||||
All requisites should be available for your distribution. The most important are :
|
All requisites should be available for your distribution. The most important are :
|
||||||
|
|
||||||
@@ -44,47 +18,25 @@ All requisites should be available for your distribution. The most important are
|
|||||||
* [Docker](https://docs.docker.com/engine/installation/)
|
* [Docker](https://docs.docker.com/engine/installation/)
|
||||||
* [Docker Compose](https://docs.docker.com/compose/install/)
|
* [Docker Compose](https://docs.docker.com/compose/install/)
|
||||||
|
|
||||||
Check if `docker-compose` is already installed by entering the following command :
|
Check if `docker-compose` is already installed by entering the following command :
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
which docker-compose
|
which docker-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
Check Docker Compose compatibility :
|
|
||||||
|
|
||||||
* [Compose file version 3 reference](https://docs.docker.com/compose/compose-file/)
|
|
||||||
|
|
||||||
The following is optional but makes life more enjoyable :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
which make
|
|
||||||
```
|
|
||||||
|
|
||||||
On Ubuntu and Debian these are available in the meta-package build-essential. On other distributions, you may need to install the GNU C++ compiler separately.
|
On Ubuntu and Debian these are available in the meta-package build-essential. On other distributions, you may need to install the GNU C++ compiler separately.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo apt install build-essential
|
sudo apt install build-essential
|
||||||
```
|
```
|
||||||
|
|
||||||
### Images to use
|
|
||||||
|
|
||||||
* [Nginx](https://hub.docker.com/_/nginx/)
|
|
||||||
* [MySQL](https://hub.docker.com/_/mysql/)
|
|
||||||
* [PHP-FPM](https://hub.docker.com/r/nanoninja/php-fpm/)
|
|
||||||
* [Composer](https://hub.docker.com/_/composer/)
|
|
||||||
* [PHPMyAdmin](https://hub.docker.com/r/phpmyadmin/phpmyadmin/)
|
|
||||||
* [Generate Certificate](https://hub.docker.com/r/jacoelho/generate-certificate/)
|
|
||||||
|
|
||||||
You should be careful when installing third party web servers such as MySQL or Nginx.
|
|
||||||
|
|
||||||
This project use the following ports :
|
This project use the following ports :
|
||||||
|
|
||||||
| Server | Port |
|
| Server | Port |
|
||||||
|------------|------|
|
|------------|------|
|
||||||
| MySQL | 8989 |
|
| MySQL | 3306 |
|
||||||
| PHPMyAdmin | 8080 |
|
| PHPMyAdmin | 8080 |
|
||||||
| Nginx | 8000 |
|
| Nginx | 80 |
|
||||||
| Nginx SSL | 3000 |
|
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -102,37 +54,6 @@ Go to the project directory :
|
|||||||
cd docker-nginx-php-mysql
|
cd docker-nginx-php-mysql
|
||||||
```
|
```
|
||||||
|
|
||||||
### Project tree
|
|
||||||
|
|
||||||
```sh
|
|
||||||
.
|
|
||||||
├── Makefile
|
|
||||||
├── README.md
|
|
||||||
├── data
|
|
||||||
│ └── db
|
|
||||||
│ ├── dumps
|
|
||||||
│ └── mysql
|
|
||||||
├── doc
|
|
||||||
├── docker-compose.yml
|
|
||||||
├── etc
|
|
||||||
│ ├── nginx
|
|
||||||
│ │ ├── default.conf
|
|
||||||
│ │ └── default.template.conf
|
|
||||||
│ ├── php
|
|
||||||
│ │ └── php.ini
|
|
||||||
│ └── ssl
|
|
||||||
└── web
|
|
||||||
├── app
|
|
||||||
│ ├── composer.json.dist
|
|
||||||
│ ├── phpunit.xml.dist
|
|
||||||
│ ├── src
|
|
||||||
│ │ └── Foo.php
|
|
||||||
│ └── test
|
|
||||||
│ ├── FooTest.php
|
|
||||||
│ └── bootstrap.php
|
|
||||||
└── public
|
|
||||||
└── index.php
|
|
||||||
```
|
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
@@ -142,17 +63,11 @@ You can change the host name by editing the `.env` file.
|
|||||||
|
|
||||||
If you modify the host name, do not forget to add it to the `/etc/hosts` file.
|
If you modify the host name, do not forget to add it to the `/etc/hosts` file.
|
||||||
|
|
||||||
1. Generate SSL certificates
|
1. Configure Nginx
|
||||||
|
|
||||||
```sh
|
Do not modify the `Website/etc/nginx/default.conf` file, it is overwritten by `Website/etc/nginx/default.template.conf`
|
||||||
source .env && sudo docker run --rm -v $(pwd)/etc/ssl:/certificates -e "SERVER=$NGINX_HOST" jacoelho/generate-certificate
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Configure Nginx
|
Edit nginx file `Website/etc/nginx/default.template.conf` and uncomment the SSL server section :
|
||||||
|
|
||||||
Do not modify the `etc/nginx/default.conf` file, it is overwritten by `etc/nginx/default.template.conf`
|
|
||||||
|
|
||||||
Edit nginx file `etc/nginx/default.template.conf` and uncomment the SSL server section :
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# server {
|
# server {
|
||||||
@@ -166,206 +81,74 @@ If you modify the host name, do not forget to add it to the `/etc/hosts` file.
|
|||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
## Configure Xdebug
|
|
||||||
|
|
||||||
If you use another IDE than [PHPStorm](https://www.jetbrains.com/phpstorm/) or [Netbeans](https://netbeans.org/), go to the [remote debugging](https://xdebug.org/docs/remote) section of Xdebug documentation.
|
|
||||||
|
|
||||||
For a better integration of Docker to PHPStorm, use the [documentation](https://github.com/nanoninja/docker-nginx-php-mysql/blob/master/doc/phpstorm-macosx.md).
|
|
||||||
|
|
||||||
1. Get your own local IP address :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo ifconfig
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Edit php file `etc/php/php.ini` and comment or uncomment the configuration as needed.
|
|
||||||
|
|
||||||
3. Set the `remote_host` parameter with your IP :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
xdebug.remote_host=192.168.0.1 # your IP
|
|
||||||
```
|
|
||||||
___
|
|
||||||
|
|
||||||
## Run the application
|
## Run the application
|
||||||
|
|
||||||
1. Copying the composer configuration file :
|
1. Start the Docker application :
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cp web/app/composer.json.dist web/app/composer.json
|
sudo make start
|
||||||
```
|
|
||||||
|
|
||||||
2. Start the application :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker-compose up -d
|
|
||||||
```
|
```
|
||||||
|
|
||||||
**Please wait this might take a several minutes...**
|
**Please wait this might take a several minutes...**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo docker-compose logs -f # Follow log output
|
sudo make logs # Follow log output
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Open your favorite browser :
|
2. Clone the required git repositories:
|
||||||
|
|
||||||
* [http://localhost:8000](http://localhost:8000/)
|
|
||||||
* [https://localhost:3000](https://localhost:3000/) ([HTTPS](#configure-nginx-with-ssl-certificates) not configured by default)
|
|
||||||
* [http://localhost:8080](http://localhost:8080/) PHPMyAdmin (username: dev, password: dev)
|
|
||||||
|
|
||||||
4. Stop and clear services
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo docker-compose down -v
|
sudo make clone
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Import the required databases:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo make import
|
||||||
|
```
|
||||||
|
|
||||||
|
4. Open your favorite browser :
|
||||||
|
|
||||||
|
* [http://localhost](http://localhost/)
|
||||||
|
* [http://localhost:8080](http://localhost:8080/) PHPMyAdmin (username: root, password: root)
|
||||||
|
|
||||||
|
5. Backup your databases:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo make backup
|
||||||
|
```
|
||||||
|
|
||||||
|
6. Restore your databases:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo make restore
|
||||||
|
```
|
||||||
|
|
||||||
|
7. Get help:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo make help
|
||||||
|
```
|
||||||
|
|
||||||
|
8. Stop the application:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo make stop
|
||||||
```
|
```
|
||||||
|
|
||||||
___
|
___
|
||||||
|
|
||||||
## Use Makefile
|
## Additional commands
|
||||||
|
|
||||||
When developing, you can use [Makefile](https://en.wikipedia.org/wiki/Make_(software)) for doing the following operations :
|
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
|---------------|----------------------------------------------|
|
|---------------|----------------------------------------------|
|
||||||
| apidoc | Generate documentation of API |
|
| clone | Clone the git repository folders |
|
||||||
| clean | Clean directories for reset |
|
| pull | Get the latest git repository updates |
|
||||||
| code-sniff | Check the API with PHP Code Sniffer (`PSR2`) |
|
| start | Create and start containers |
|
||||||
| composer-up | Update PHP dependencies with composer |
|
| stop | Stop all containers |
|
||||||
| docker-start | Create and start containers |
|
| restart | Restart all containers |
|
||||||
| docker-stop | Stop and clear all services |
|
| logs | Display log output |
|
||||||
| gen-certs | Generate SSL certificates for `nginx` |
|
| import | Import all databases from git repositories |
|
||||||
| logs | Follow log output |
|
| backup | Create backup of all local databases |
|
||||||
| mysql-dump | Create backup of all databases |
|
| restore | Restore backup of all local databases |
|
||||||
| mysql-restore | Restore backup of all databases |
|
| flush | Delete local git repository folders |
|
||||||
| phpmd | Analyse the API with PHP Mess Detector |
|
|
||||||
| test | Test application with phpunit |
|
|
||||||
|
|
||||||
### Examples
|
|
||||||
|
|
||||||
Start the application :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo make docker-start
|
|
||||||
```
|
|
||||||
|
|
||||||
Show help :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
make help
|
|
||||||
```
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
## Use Docker commands
|
|
||||||
|
|
||||||
### Installing package with composer
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker run --rm -v $(pwd)/web/app:/app composer require symfony/yaml
|
|
||||||
```
|
|
||||||
|
|
||||||
### Updating PHP dependencies with composer
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker run --rm -v $(pwd)/web/app:/app composer update
|
|
||||||
```
|
|
||||||
|
|
||||||
### Generating PHP API documentation
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker-compose exec -T php php -d memory_limit=256M -d xdebug.profiler_enable=0 ./app/vendor/bin/apigen generate app/src --destination ./app/doc
|
|
||||||
```
|
|
||||||
|
|
||||||
### Testing PHP application with PHPUnit
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker-compose exec -T php ./app/vendor/bin/phpunit --colors=always --configuration ./app
|
|
||||||
```
|
|
||||||
|
|
||||||
### Fixing standard code with [PSR2](http://www.php-fig.org/psr/psr-2/)
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker-compose exec -T php ./app/vendor/bin/phpcbf -v --standard=PSR2 ./app/src
|
|
||||||
```
|
|
||||||
|
|
||||||
### Checking the standard code with [PSR2](http://www.php-fig.org/psr/psr-2/)
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker-compose exec -T php ./app/vendor/bin/phpcs -v --standard=PSR2 ./app/src
|
|
||||||
```
|
|
||||||
|
|
||||||
### Analyzing source code with [PHP Mess Detector](https://phpmd.org/)
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker-compose exec -T php ./app/vendor/bin/phpmd ./app/src text cleancode,codesize,controversial,design,naming,unusedcode
|
|
||||||
```
|
|
||||||
|
|
||||||
### Checking installed PHP extensions
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker-compose exec php php -m
|
|
||||||
```
|
|
||||||
|
|
||||||
### Handling database
|
|
||||||
|
|
||||||
#### MySQL shell access
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo docker exec -it mysql bash
|
|
||||||
```
|
|
||||||
|
|
||||||
and
|
|
||||||
|
|
||||||
```sh
|
|
||||||
mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Creating a backup of all databases
|
|
||||||
|
|
||||||
```sh
|
|
||||||
mkdir -p data/db/dumps
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh
|
|
||||||
source .env && sudo docker exec $(sudo docker-compose ps -q mysqldb) mysqldump --all-databases -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" > "data/db/dumps/db.sql"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Restoring a backup of all databases
|
|
||||||
|
|
||||||
```sh
|
|
||||||
source .env && sudo docker exec -i $(sudo docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/db.sql"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Creating a backup of single database
|
|
||||||
|
|
||||||
**`Notice:`** Replace "YOUR_DB_NAME" by your custom name.
|
|
||||||
|
|
||||||
```sh
|
|
||||||
source .env && sudo docker exec $(sudo docker-compose ps -q mysqldb) mysqldump -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" --databases YOUR_DB_NAME > "data/db/dumps/YOUR_DB_NAME_dump.sql"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Restoring a backup of single database
|
|
||||||
|
|
||||||
```sh
|
|
||||||
source .env && sudo docker exec -i $(sudo docker-compose ps -q mysqldb) mysql -u"$MYSQL_ROOT_USER" -p"$MYSQL_ROOT_PASSWORD" < "data/db/dumps/YOUR_DB_NAME_dump.sql"
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### Connecting MySQL from [PDO](http://php.net/manual/en/book.pdo.php)
|
|
||||||
|
|
||||||
```php
|
|
||||||
<?php
|
|
||||||
try {
|
|
||||||
$dsn = 'mysql:host=mysql;dbname=test;charset=utf8;port=3306';
|
|
||||||
$pdo = new PDO($dsn, 'dev', 'dev');
|
|
||||||
} catch (PDOException $e) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
```
|
|
||||||
|
|
||||||
___
|
|
||||||
|
|
||||||
## Help us
|
|
||||||
|
|
||||||
Any thought, feedback or (hopefully not!)
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
# Configure Local CA CERT with MacOS
|
|
||||||
|
|
||||||
## 1. The warning you receive while developing locally.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 2. Open the keychain app.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 3. Use File --> Import to add the ca cert you've already created.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 4. Once added, locate it via the search box.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 5. Set to always trust.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 6. Reload the webpage.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 211 KiB |
|
Before Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 226 KiB |
|
Before Width: | Height: | Size: 330 KiB |
|
Before Width: | Height: | Size: 408 KiB |
|
Before Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 413 KiB |
|
Before Width: | Height: | Size: 520 KiB |
|
Before Width: | Height: | Size: 403 KiB |
|
Before Width: | Height: | Size: 594 KiB |
|
Before Width: | Height: | Size: 562 KiB |
|
Before Width: | Height: | Size: 559 KiB |
|
Before Width: | Height: | Size: 461 KiB |
|
Before Width: | Height: | Size: 525 KiB |
|
Before Width: | Height: | Size: 646 KiB |
@@ -1,71 +0,0 @@
|
|||||||
# Configure PHPStorm with MacOS
|
|
||||||
|
|
||||||
Inspired from this following links :
|
|
||||||
|
|
||||||
- [Running PHPUnit Tests in PhpStorm with Docker](https://www.youtube.com/watch?v=I7aGWO6K3Ho)
|
|
||||||
- [All hail Xdebug and lets let var dump die](http://jamescowie.me/blog/2016/12/all-hail-xdebug-and-lets-let-var-dump-die/)
|
|
||||||
|
|
||||||
## Edit PHP configuration
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Add a PHP interpreter
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Configure PHPUnit
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### Add test configuration
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### PHPUnit Demo
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## Configure XDebug
|
|
||||||
|
|
||||||
### Edit `etc/php.ini` file
|
|
||||||
|
|
||||||
Add this following lines :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
[xdebug]
|
|
||||||
xdebug.remote_host = 10.254.254.254
|
|
||||||
xdebug.remote_port = 9000
|
|
||||||
xdebug.remote_autostart=1
|
|
||||||
xdebug.idekey = PHPSTORM
|
|
||||||
xdebug.remote_enable = 1
|
|
||||||
xdebug.remote_connect_back = 0
|
|
||||||
xdebug.profiler_enable = 1
|
|
||||||
```
|
|
||||||
|
|
||||||
### Check Debug section
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### Add a debug server
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### Configure XDebug Proxy
|
|
||||||
|
|
||||||
Create an IP Alias :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo ifconfig en0 alias 10.254.254.254 255.255.255.0
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
To delete an IP Alias :
|
|
||||||
|
|
||||||
```sh
|
|
||||||
sudo ifconfig en0 -alias 10.254.254.254
|
|
||||||
```
|
|
||||||
|
|
||||||
### XDebug Demo
|
|
||||||
|
|
||||||

|
|
||||||
@@ -3,10 +3,10 @@ services:
|
|||||||
web:
|
web:
|
||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
volumes:
|
volumes:
|
||||||
- "./etc/nginx/default.conf:/etc/nginx/conf.d/default.conf"
|
- "./Website/etc/nginx/default.conf:/etc/nginx/conf.d/default.conf"
|
||||||
- "./etc/ssl:/etc/ssl"
|
- "./Website/etc/ssl:/etc/ssl"
|
||||||
- "./Open-RSC-Website:/var/www/html/public"
|
- "./Website/Open-RSC-Website:/var/www/html/public"
|
||||||
- "./etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template"
|
- "./Website/etc/nginx/default.template.conf:/etc/nginx/conf.d/default.template"
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
- "443:443"
|
- "443:443"
|
||||||
@@ -21,8 +21,8 @@ services:
|
|||||||
image: nanoninja/php-fpm:${PHP_VERSION}
|
image: nanoninja/php-fpm:${PHP_VERSION}
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- "./etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
|
- "./Website/etc/php/php.ini:/usr/local/etc/php/conf.d/php.ini"
|
||||||
- "./Open-RSC-Website:/var/www/html/public"
|
- "./Website/Open-RSC-Website:/var/www/html/public"
|
||||||
myadmin:
|
myadmin:
|
||||||
image: phpmyadmin/phpmyadmin
|
image: phpmyadmin/phpmyadmin
|
||||||
container_name: phpmyadmin
|
container_name: phpmyadmin
|
||||||
@@ -48,4 +48,4 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
volumes:
|
volumes:
|
||||||
- "./data/db/mysql:/var/lib/mysql"
|
- "./Website/data/db/mysql:/var/lib/mysql"
|
||||||
|
|||||||