|
1 | | -# Requirements |
| 1 | +## Environment composition |
2 | 2 |
|
3 | | -- [docker](https://www.docker.com/products/overview) |
4 | | -- [docker-compose](https://docs.docker.com/compose/install/) |
| 3 | +This environment provies the following tools to develop in PHP : |
5 | 4 |
|
6 | | -## Windows |
| 5 | +### Core |
| 6 | +- [PHP](http://php.net) |
7 | 7 |
|
8 | | -Windows 7 or higher with support for virtualization. |
| 8 | +Available version : |
9 | 9 |
|
10 | | -### Git |
| 10 | + - `5.6` |
| 11 | + - `7.0` |
| 12 | + - `7.1` |
| 13 | + - `7.2` |
11 | 14 |
|
12 | | -The following configuration is necessary : |
| 15 | +The version is configured in `.env` file. Default: `7.2` |
| 16 | +PHP Stack run on Alpine version to keep a small size image. |
13 | 17 |
|
14 | | -``` |
15 | | -$ git config core.autocrlf false |
16 | | -``` |
| 18 | +- Database |
| 19 | + |
| 20 | +Two different database are available : |
| 21 | + |
| 22 | + - [MySQL](https://www.mysql.com) |
| 23 | + - [MongoDB](https://www.mongodb.com) |
| 24 | + |
| 25 | +The database wished is configured in `.env` file. Default: `mysql` |
| 26 | + |
| 27 | +- Web server |
| 28 | + |
| 29 | +Two web server are available : |
| 30 | + |
| 31 | + - [Nginx](https://nginx.org) |
| 32 | + - [Apache](https://httpd.apache.org/) |
| 33 | + |
| 34 | +All of them are in Alpine version. |
| 35 | + |
| 36 | +- Cache server |
| 37 | + |
| 38 | +Two cache server are available : |
| 39 | + |
| 40 | + - [Redis](https://redis.io/) |
| 41 | + - [Memcached](https://memcached.org/) |
| 42 | + |
| 43 | +All of them are in Alpine version |
| 44 | + |
| 45 | +### Tools |
| 46 | + |
| 47 | +#### Database admin |
| 48 | + |
| 49 | +- [MongoExpress](https://github.com/mongo-express/mongo-express) : Manage Mongo database instances |
| 50 | +- [PHPMyAdmin](https://www.phpmyadmin.net/) : Manage Mongo database instances |
| 51 | + |
| 52 | +#### Mail hub |
| 53 | + |
| 54 | +- [MailDev](http://danfarrelly.nyc/MailDev) : SMTP Server + Web Interface for viewing and testing emails during development |
| 55 | + |
| 56 | +#### Composer |
| 57 | + |
| 58 | +- [Composer](https://getcomposer.org) : Dependency Manager for PHP |
17 | 59 |
|
18 | | -# Installation |
| 60 | +#### NodeJs |
| 61 | + |
| 62 | +- [NodeJs](https://nodejs.org/en) : JavaScript runtime |
| 63 | + |
| 64 | +### Optional tools |
| 65 | + |
| 66 | +Optional tools are available to use in EnvDev. They are not included by default but can be added easily. |
| 67 | + |
| 68 | +- [APIGen](https://github.com/ApiGen/ApiGen) : Documentation for your PHP project |
| 69 | + |
| 70 | +Image container : [`vfac/apigen`](https://hub.docker.com/r/vfac/apigen/) |
| 71 | + |
| 72 | +- [Deployer](https://deployer.org) : Deployment tool for PHP |
| 73 | + |
| 74 | +Image container : [`vfac/deployer`](https://hub.docker.com/r/vfac/deployer/) |
| 75 | + |
| 76 | +## Requirements |
| 77 | + |
| 78 | +Two system dependencies are required : |
| 79 | +- Docker |
| 80 | +- Docker Compose |
| 81 | + |
| 82 | +## Installation |
19 | 83 |
|
20 | 84 | ``` |
21 | 85 | $ git clone [email protected]:vfalies/EnvDev.git |
22 | 86 | ``` |
23 | 87 |
|
24 | | -# Usage |
| 88 | +## Usage |
| 89 | + |
| 90 | +To start the environment, type the following command: |
25 | 91 |
|
26 | 92 | ``` |
27 | 93 | $ docker-compose up |
28 | 94 | ``` |
29 | 95 |
|
30 | | -# Documentation |
| 96 | +Several containers are created from `.env` configuration: |
| 97 | + |
| 98 | +| Description | Container's name | |
| 99 | +|-------------|------------------| |
| 100 | +| Maildev hub mail | `maildev` | |
| 101 | +| NodeJs | `nodejs` | |
| 102 | +| Web server ( Apache or Nginx ) | `web` | |
| 103 | +| PHP container | `php` | |
| 104 | +| Cache server | `cache` | |
| 105 | +| Database server | `db` | |
| 106 | +| Database admin tool | `dbadmin` | |
| 107 | + |
| 108 | +`composer` is available through `php` container: |
| 109 | + |
| 110 | +``` |
| 111 | +docker exec php composer -v |
| 112 | +``` |
| 113 | + |
| 114 | +`node`, `npm` are available through `node` container: |
| 115 | + |
| 116 | +``` |
| 117 | +docker run --rm node node -v |
| 118 | +``` |
| 119 | + |
| 120 | +``` |
| 121 | +docker run --rm node npm -v |
| 122 | +``` |
| 123 | + |
| 124 | +### Hosts |
| 125 | + |
| 126 | +You can add your own hosts file for all your projects. |
| 127 | + |
| 128 | +With NGinx |
| 129 | + |
| 130 | +In `conf/nginx/vhosts` directory, all your `yourhost.conf` file. A default host file is available for example : `/conf/nginx/vhosts/default.conf`. |
| 131 | + |
| 132 | +``` |
| 133 | +server { |
| 134 | +
|
| 135 | + listen 80; |
| 136 | + server_name localhost; |
| 137 | + root /var/www/html; |
| 138 | + index index.php index.html index.htm; |
| 139 | +
|
| 140 | + location ~* \.PHP$ { |
| 141 | + fastcgi_index index.php; |
| 142 | + fastcgi_pass php:9000; |
| 143 | + include fastcgi_params; |
| 144 | + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
| 145 | + } |
| 146 | +
|
| 147 | +} |
| 148 | +``` |
| 149 | + |
| 150 | +With Apache |
| 151 | + |
| 152 | +In `conf/apache/vhosts` directory, all your `yourhost.conf` file. A default host file is available for example : `/conf/apache/vhosts/default.conf`. |
| 153 | + |
| 154 | +``` |
| 155 | +<VirtualHost *:80> |
| 156 | + ServerName localhost |
| 157 | + DocumentRoot /var/www/html |
| 158 | +
|
| 159 | + <Directory /var/www/html> |
| 160 | + Require all granted |
| 161 | + </Directory> |
| 162 | +
|
| 163 | + <FilesMatch \.php$> |
| 164 | + SetHandler "proxy:fcgi://php:9000" |
| 165 | + </FilesMatch> |
| 166 | +</VirtualHost> |
| 167 | +``` |
| 168 | + |
| 169 | +## Configuration |
| 170 | + |
| 171 | +You can modify `.env` file to manage applications and tools. |
| 172 | +The following versions, paths and ports can be configured : |
| 173 | + |
| 174 | +| Description | Variable name | Possible values | Default | |
| 175 | +|:-------------|:---------------:|:-----------------:|:---------:| |
| 176 | +| PHP Version | PHP_VERSION | `5.6`, `7.0`, `7.1`, `7.2` | `7.2` | |
| 177 | +| Database type | DB | `mariadb`, `mysql`, `mongodb` | `mysql` | |
| 178 | +| Cache server type | CACHE_SERVER | `redis`, `memcached` | `redis` | |
| 179 | +| Projects Path | PROJECTS_PATH | any | `./projects` | |
| 180 | +| HTTP web port | WEB_PORT | any | `80` | |
| 181 | +| MailDev port | MAILDEV_PORT | any | `1080` | |
| 182 | +| PHPMyAdmin port | PHPMYADMIN_PORT | any | `9090` | |
| 183 | +| MongoExpress port | MONGOEXPRESS_PORT | any | `8081` | |
| 184 | +| Cache server port | CACHE_PORT | any | `6380` | |
| 185 | + |
| 186 | +If you access to the url `http://localhost` a page summarizes all projets and propose access link to PHPMyAdmin, MailDev and PHPInfo. |
| 187 | + |
| 188 | +### Nginx configuration |
| 189 | + |
| 190 | +Nginx configuration file is available at `/conf/nginx/nginx.conf` to custom the web server configuration. |
| 191 | + |
| 192 | +### Apache configuration |
| 193 | + |
| 194 | +Apache configuration file is available at `/conf/apache/httpd.conf` to custom the web server configuration. |
| 195 | + |
| 196 | +### PHP configuration |
| 197 | + |
| 198 | +A custom php.ini file is available at `/conf/php/php.ini`. The default PHP configuration is with these options: |
| 199 | + |
| 200 | +``` |
| 201 | +date.timezone = Europe/Paris |
| 202 | +display_errors=1 |
| 203 | +error_reporting=E_ALL |
| 204 | +log_errors = on |
| 205 | +error_log = /var/log/php_errors.log |
| 206 | +memory_limit = 256M |
| 207 | +upload_max_filesize = 200M |
| 208 | +post_max_size = 40M |
| 209 | +``` |
| 210 | + |
| 211 | +### Projects configuration |
| 212 | + |
| 213 | +To simplify projects source sharing between containers, you can install source projects in the path define in `.env` with variable `PROJECTS_PATH`. |
| 214 | + |
| 215 | +Naturally, you can change the default path. In this case, the default summary will not be available. |
| 216 | + |
| 217 | +## Open source |
31 | 218 |
|
32 | | -The complete documentation is avaiable on https://vfac.fr/envdev |
| 219 | +EnvDev is licensed under the MIT License and published through [GitHub](https://github.com/vfalies/envdev/blob/master/LICENSE) |
0 commit comments