|
| 1 | +PHP basic developer environment |
| 2 | +=============================== |
| 3 | + |
| 4 | +Basic developer environment for Wordpress apps. |
| 5 | + |
| 6 | +Usage |
| 7 | +----- |
| 8 | + |
| 9 | +For your convenience the developer environment has some helpers which take away |
| 10 | +some difficulties you could experience using docker containers. |
| 11 | + |
| 12 | +If you want this easy helpers to be readily available for you you can use |
| 13 | +`environment` before you start. `environment` allows you to start your |
| 14 | +environment with an updated `PATH` and allows you to choose between `tmux`, |
| 15 | +`screen` or `byobu`. You can also define a default in the .env file. |
| 16 | + |
| 17 | +explicit setting the window manager: |
| 18 | + |
| 19 | +~~~ sh |
| 20 | +$ ./environment [tmux|screen|byobu] |
| 21 | +~~~ |
| 22 | + |
| 23 | +using default window manager, defined in .env |
| 24 | + |
| 25 | +~~~ sh |
| 26 | +$ ./environment |
| 27 | +~~~ |
| 28 | + |
| 29 | +When you are running in this environment all helpers are available in your path. |
| 30 | + |
| 31 | +You are not required to use the environent, but then you have to call the |
| 32 | +helpers with their full path. |
| 33 | + |
| 34 | +To make use of the helpers you should use the `run` wrapper for `docker-compose`. |
| 35 | + |
| 36 | +~~~ sh |
| 37 | +$ run up |
| 38 | +~~~ |
| 39 | + |
| 40 | +Configuration |
| 41 | +------------- |
| 42 | + |
| 43 | +There is a sample configuration `.env-sample` which contains the defaults used |
| 44 | +in this environment. |
| 45 | + |
| 46 | +If you want to change some of these values, copy `.env-sample` to `.env` and |
| 47 | +start editing. |
| 48 | + |
| 49 | +default `.env-sample` |
| 50 | + |
| 51 | +~~~ |
| 52 | +C_UID=1000 |
| 53 | +C_GID=1000 |
| 54 | +PHPVERSION=7.1 |
| 55 | +NGINXVERSION=stable |
| 56 | +BASEHOST=application.dev |
| 57 | +MYSQL_ROOT_PASSWORD=toor |
| 58 | +APPLICATION=../application |
| 59 | +DEVELOPMENT=1 |
| 60 | +WINDOW_MANAGER=tmux |
| 61 | +~~~ |
| 62 | + |
| 63 | +### C_UID / C_GID |
| 64 | + |
| 65 | +Configure what UID and GID your PHP container must use. This usually should |
| 66 | +match your Hosts UID and GID. To find your local UID you can run `id -u` and to |
| 67 | +find your local GID you can run `id -g`. |
| 68 | + |
| 69 | +### PHPVERSION |
| 70 | + |
| 71 | +Choose your PHP version. To see which versions are available |
| 72 | +[here](https://gitlab.com/dockerwest/image/php-wordpress). |
| 73 | + |
| 74 | +### NGINXVERSION |
| 75 | + |
| 76 | +Choose what version of Nginx you want. To see which versions are available see |
| 77 | +[here](https://gitlab.com/dockerwest/image/nginx-wordpress) |
| 78 | + |
| 79 | +### BASEHOST |
| 80 | + |
| 81 | +This setting defines what the hostname will be you can browse your wordpress app. |
| 82 | +The example configuration will be give you `http://application.dev`. |
| 83 | + |
| 84 | +### MYSQL_ROOT_PASSWORD |
| 85 | + |
| 86 | +Choose whatever you want to use as default root password. |
| 87 | + |
| 88 | +### APPLICATION |
| 89 | + |
| 90 | +A relative or absolute path to your application code. this can be a checkout of any wordpress project |
| 91 | + |
| 92 | +### DEVELOPMENT |
| 93 | + |
| 94 | +There is the `DEVELOPMENT` environment variable wich will enable xdebug, |
| 95 | +composer and enable timestamp checking in opcache. |
| 96 | + |
| 97 | +When `DEVELOPMENT` is enabled xdebug should work out of the box. When you have |
| 98 | +issues - like while running docker for mac - you can set the extra environment |
| 99 | +variable `XDEBUG_CONFIG` with your hosts ip in it so xdebug can properly |
| 100 | +connect back. |
| 101 | + |
| 102 | +### WINDOW_MANAGER |
| 103 | +Set the default window manager when running the environment. |
| 104 | +Available options are: tmux, screen and byobu |
| 105 | + |
| 106 | +Helpers |
| 107 | +------- |
| 108 | + |
| 109 | +The helpers are written in python, so you should have python2 or python3 |
| 110 | +installed on your system to be able to use them. Most Linux distributions and |
| 111 | +macOS have python already installed so there should be no issue there. There |
| 112 | +are no extra dependencies on python modules. |
| 113 | + |
| 114 | +### wp |
| 115 | + |
| 116 | +Run the [wp](https://wp-cli.org) command inside the running php container, or inside a php-wordpress container if none is running. |
| 117 | +The working directory will be the current directory you are executing this command from. |
| 118 | + |
| 119 | +eg. `$ wp --version` |
| 120 | + |
| 121 | +### composer |
| 122 | + |
| 123 | +Run the [composer](https://getcomposer.org/) command inside the php docker container. |
| 124 | +The working directory will be the current directory you are executing this command from. |
| 125 | +Your $HOME/.ssh and $HOME/.composer folders wil be mounted inside this container to enable you to make use of your ssh keys and composer cache. |
| 126 | + |
| 127 | +eg. `$ composer require package_name` |
| 128 | + |
| 129 | +### create_db |
| 130 | +Create a new database inside the running mysql container with the name 'pimcore' and 'DEFAULT CHARSET utf8'. |
| 131 | + |
| 132 | +eg. `$ create_db` |
| 133 | + |
| 134 | +### mysql |
| 135 | +Execute a mysql command inside the running mysql container as the root user. |
| 136 | + |
| 137 | +eg. `$ mysql "SELECT * FROM table_name;"` |
| 138 | + |
| 139 | +### mysqldump |
| 140 | +Execute the mysqldump command inside the running mysql container as the root user. |
| 141 | + |
| 142 | +eg. `$ mysqldump db_name > export_file_name.sql` |
| 143 | + |
| 144 | +### mysqlimport |
| 145 | +Import a given mysql file into a given database, inside the running mysql container as the root user. |
| 146 | + |
| 147 | +eg. `$ mysqlimport db_name import_file_name.sql` |
| 148 | + |
| 149 | +### node |
| 150 | +Execute the [node](https://nodejs.org) command inside a node container. |
| 151 | +The working directory will be the current directory you are executing this command from. |
| 152 | + |
| 153 | +eg. `$ node js_file.js` |
| 154 | + |
| 155 | +### npm |
| 156 | +Execute the [npm](https://www.npmjs.com/) command inside a node container. |
| 157 | +The working directory will be the current directory you are executing this command from. |
| 158 | +Your $HOME/.ssh and $HOME/.npm folders wil be mounted inside this container to enable you to make use of your ssh keys and npm cache. |
| 159 | + |
| 160 | +eg. `$ npm install package_name` |
| 161 | + |
| 162 | +### yarn |
| 163 | +Execute the [yarn](https://yarnpkg.com) command inside a node container. |
| 164 | +The working directory will be the current directory you are executing this command from. |
| 165 | +Your $HOME/.ssh and $HOME/.npm folders wil be mounted inside this container to enable you to make use of your ssh keys and npm cache. |
| 166 | + |
| 167 | +eg. `$ yarn add package_name` |
| 168 | + |
| 169 | +### php |
| 170 | +Execute the php command inside the running php container, or inside a php-pimcore container if none is running. |
| 171 | +The working directory will be the current directory you are executing this command from. |
| 172 | + |
| 173 | +eg. `$ php -v` |
| 174 | + |
| 175 | +### redis-cli |
| 176 | +Execute the [redis-cli](https://redis.io/topics/rediscli) command in the running redis container. |
| 177 | + |
| 178 | +eg. `$ redis-cli flushall` |
| 179 | + |
| 180 | +### run |
| 181 | +Run docker-compose for the current project, setting the project name to the BASEHOST variable from the .env file |
| 182 | + |
| 183 | +eg. `$ run up` |
| 184 | + |
| 185 | +Tricks |
| 186 | +------ |
| 187 | + |
| 188 | +### macOS |
| 189 | + |
| 190 | +For this environment to work properly you should install gnu coreutils |
| 191 | + |
| 192 | +using homebrew: |
| 193 | + |
| 194 | +~~~ sh |
| 195 | +$ brew install coreutils |
| 196 | +~~~ |
| 197 | + |
| 198 | +On macOS you could just install docker from the docker site and run like this. |
| 199 | +But our experience is that the native docker install is fairly slow to use. We |
| 200 | +would suggest you to install [dinghy](https://github.com/codekitchen/dinghy). |
| 201 | + |
| 202 | +[install dinghy](https://github.com/codekitchen/dinghy#install) and install the |
| 203 | +VM technology you want to use. If you want native xhyve support you can |
| 204 | +additionally install |
| 205 | +[xhyve driver for docker machine](https://github.com/zchee/docker-machine-driver-xhyve). |
| 206 | + |
| 207 | +If you have dinghy installed this environment will try to use it. |
| 208 | + |
| 209 | +Currently there is an annoying limitation when we are using dinghy and that is |
| 210 | +that the hostnames used must end with `docker`. |
| 211 | + |
| 212 | +### oh-my-zsh users |
| 213 | + |
| 214 | +[oh-my-zsh](http://ohmyz.sh/) users should check if there is no fixed setting |
| 215 | +for `$PATH` in their `~/.zshrc`. If that is the case you can safely comment it |
| 216 | +out. If somewhere in your shell startup `$PATH` is forced you lose the features |
| 217 | +the `./environment` script brings to you. |
| 218 | + |
| 219 | +License |
| 220 | +------- |
| 221 | + |
| 222 | +MIT License (MIT). See [License File](LICENSE.md) for more information. |
0 commit comments