## How to use this template

### Create a new project folder

Copy downloaded and extracted folder to a new name:

```shell
cp -r docker-php-starterkit my-new-php-app
```

OR

```shell
git clone https://gitlab.iml.unibe.ch/iml-open-source/docker-php-starterkit.git my-new-php-app 
```

In the new folder remove the docs of the kit and its git repo

```shell
cd my-new-php-app && rm -rf docs .git
```

The initial file structure looks like this:

```txt
.
├── docker                         # Docker data
│  ├── init.sh                       << shellscript for initialization
│  ├── init.sh.cfg                   << config file
│  └── templates                     << folder with templates
│     ├── docker-compose.yml
│     ├── dot_env
│     ├── extra-php-config.ini
│     ├── my.cnf
│     ├── readme.md
│     ├── vhost_app.conf
│     └── web-server-Dockerfile
├── public_html                    # your webroot for your project
│  └── index.php
└── readme.md
```

### Edit variables and files

* edit ```./docker/init.sh.cfg``` ... and edit
  * ```APP_NAME=my_new_app```
  * optional: set a new port ```APP_PORT=8001```
  * set APP_* variables for packages to install or PHP version
  * set DB_ADD to true or false to say if a database container is needed
  * If a database is needed then set DB_PORT and MYSQL_* variables
* edit ```./docker/templates/vhost_app.conf``` to describe apache vhost config
* edit php settings in ```./docker/templates/extra-php.ini```
* edit mysql settings in ```./docker/templates/my.cnf```

### First start

* start init script in the docker folder: ```./docker/init.sh```
  * use `g` to remove git data of the starterkit
  * use `i` for init ... it sets an ACL on the ./public_html/ subdir to allow write access for your current user and the apache user in the docker container
  * use `t` to generate config files from templates with the settings from ./docker/init.sh.cfg
  * use `u` to bring up the container (OR run ```docker-compose up -d``` )

### Edit files

* If the container was started you can ...
  * open in your browser http://localhost:8001 to access ```./public_html/```
  * edit files with the IDE of your choice

### Remarks

You can start ./docker/init.sh with a single letter in the interactive menu too, i.e. ```./docker/init.sh u``` to bring up the docker instance.

If you created the config files from templates you can repeat the creation ```./docker/init.sh t```. Before applying a change you should shutdown your docker instance.