# Xaver Bertsch

Xaver Bertsch Shopware 6 (xps-store.de)

## creating a new database for a new feature stage

- Log in to PhpMyAdmin (https://pma.xps-store.de/) with the admin data
- Create the new database under Databases
    - Use 'xb_stage' as the prefix. E.g. xb_stage_t_as237862_23
- Select the database and then create a new user under 'Rights' (Rechte) and 'Add user account' (Benutzerkonto hinzufügen)
    - Use 'usr_xb_stage' as the prefix. E.g. usr_xb_stage_t_as237862_23
- Activate the option 'Grant all rights to the database' with the database name created

## Setting up docker environment

### Installing docker

Install docker: [https://docs.docker.com/get-docker/](https://docs.docker.com/get-docker/)

### Dumping mysql database from live system

1. upload the following files into live server. E. g. for an example in home directory and in a new folder 'dd_bkp'
2. add database details from live system in .env
3. Add execution rights for the script: `chmod u+x create_db_dump.sh`
4. run dump script: `cd ~/dd_bkp && ./create_db_dump.sh`
5. download the dump in gzip format
6. rename file to database.sql.gz and put it into your project folder: docker/files/database.sql.gz

### Creating docker container

1. `cd docker && docker-compose -p "#PROJECT_NAME#" up -d`. Set '#PROJECT_NAME#' to the desired name
    - Execute `docker logs --follow #CONTAINER_NAME#` to follow the output of the container. See [Using docker container](#Using-docker-container) to know how to get the container name
    - The container is ready when you see the section "WOHOOO, dockware/essentials:*** IS READY"

#### Using docker container

- to stop container: `docker stop #CONTAINER_NAME#`
- to start container: `docker start #CONTAINER_NAME#`
- log into bash: `docker exec -it #CONTAINER_NAME# bash`
- see log of the container: `docker logs --follow #CONTAINER_NAME#`

> replace #CONTAINER_NAME# with the name of your created container. Use the command `docker ps` and search for the line with dockware/essentials. Get the name of the container from the NAMES column.

### Add hosts entry

Add following line into /etc/hosts:
`127.0.0.1 local.xps.de`

### How to update database in your docker container

- stop container stack within docker folder: `docker-compose stop`
- remove container: `docker rm #MYSQL_CONTAINER_NAME#`
- remove mysql volume: `docker volume rm #MYSQL_VOLUME_NAME#`
- start container stack within docker folder: `docker-compose -p "#PROJECT_NAME#" up -d`
- compile theme in shopware container: `cd /var/www/html && ./bin/console theme:compile`
- clear cache in shopware container: `cd /var/www/html && ./bin/console cache:clear`

### URL Details

- SHOP URL: https://local.xps.de
- SHOP-ADMIN URL: https://local.xps.de/admin/
- ADMINER URL: https://local.xps.de/adminer.php
    - Use for host 127.0.0.1 and root as username and password
- MAILCATCHER URL: https://local.xps.de/mailcatcher
- PIMPMYLOG URL: https://local.xps.de/logs

### General notes

Thumbnails and media files are loaded from live system 
