engelsystem/README.md

214 lines
8.0 KiB
Markdown
Raw Normal View History

[![pipeline status](https://chaos.expert/engelsystem/engelsystem/badges/master/pipeline.svg)](https://chaos.expert/engelsystem/engelsystem/commits/master)
[![coverage report](https://chaos.expert/engelsystem/engelsystem/badges/master/coverage.svg)](https://chaos.expert/engelsystem/engelsystem/commits/master)
2016-08-21 17:26:03 +02:00
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/20b3b0b4e93344a29da6bec77f329e7a)](https://www.codacy.com/app/engelsystem/engelsystem)
2016-08-24 17:58:39 +02:00
[![GPL](https://img.shields.io/github/license/engelsystem/engelsystem.svg?maxAge=2592000)]()
2016-08-21 17:24:04 +02:00
# Engelsystem
Please visit https://engelsystem.de for a feature list.
To report bugs use [engelsystem/issues](https://github.com/engelsystem/engelsystem/issues)
## Installation
### Requirements
* PHP >= 7.2
* Required modules:
2019-03-17 09:22:30 +01:00
* dom
* json
* mbstring
* PDO
* mysql
2019-03-17 09:31:19 +01:00
* tokenizer
* xml/libxml/SimpleXML
2019-03-17 09:30:29 +01:00
* xmlwriter
* MySQL-Server >= 5.7.8 or MariaDB-Server >= 10.2.2
* Webserver, i.e. lighttpd, nginx, or Apache
### Additional requirements if you want to build the project by yourself
* Node >= 8 (Development/Building only)
* Yarn (Development/Building only)
2019-03-17 09:14:17 +01:00
* PHP Composer (Development/Building only)
2019-04-05 16:57:07 +02:00
#### This should be included in your node install
* npm (Development/Building only)
### Download
#### Stable
* Go to the [Releases](https://github.com/engelsystem/engelsystem/releases) page and download the latest stable release file.
* Extract the files to your webroot and continue with the directions for configurations and setup.
2019-01-13 13:11:50 +01:00
#### Latest unstable
The following instructions explain how to get, build and run the latest engelsystem version directly from the git master branch (may be unstable!).
* Clone the master branch: `git clone https://github.com/engelsystem/engelsystem.git`
* Install [Composer](https://getcomposer.org/download/) and [Yarn](https://yarnpkg.com/en/docs/install) (which requires [Node.js](https://nodejs.org/en/download/package-manager/))
* Install project dependencies:
```bash
composer install
yarn
```
On production systems it is recommended to use
```bash
composer install --no-dev
2017-12-25 23:12:52 +01:00
composer dump-autoload --optimize
```
to install the engelsystem
* Build the frontend assets
```bash
yarn build
```
* Optionally (for better performance)
* Generate translation files
```bash
find resources/lang/ -type f -name '*.po' -exec sh -c 'file="{}"; msgfmt "${file%.*}.po" -o "${file%.*}.mo"' \;
```
2018-05-03 18:06:54 +02:00
### Configuration and Setup
* The webserver must have write access to the ```storage``` directory and read access for all other directories
2018-01-28 14:29:13 +01:00
* The webserver must point to the ```public``` directory.
* The webserver must read the ```.htaccess``` file and ```mod_rewrite``` must be enabled
* Recommended: Directory Listing should be disabled.
* There must a be MySQL database created with a user who has full rights to that database.
2018-01-28 14:29:13 +01:00
* If necessary, create a ```config/config.php``` to override values from ```config/config.default.php```.
2018-10-27 12:11:37 +02:00
* To remove values from the `footer_items`, `available_themes`, `locales`, `tshirt_sizes` or `headers` lists the config file has to be renamed.
2019-01-13 13:05:07 +01:00
* To import the database the ```bin/migrate``` script has to be called. If you are not allowed to execute scripts, then execute the ```install-<version>.sql``` script. Download at [Releases](https://github.com/engelsystem/engelsystem/releases) page.
2019-10-28 20:59:43 +01:00
* In the browser, login with credentials ```admin``` : ```asdfasdf``` and change the password.
Engelsystem can now be used.
### Session Settings:
* Make sure the config allows for sessions.
* Both Apache and Nginx allow for different VirtualHost configurations.
2014-11-12 19:45:55 +01:00
## Development
Since the engelsystem is open source, you can help to improve the system. We really love to get pull requests containing fixes or implementations of our Github issues.
Please create single pull requests for every feature instead of creating one big monster of pull request containing a complete rewrite.
### Testing
To run the unit tests use
```bash
vendor/bin/phpunit --testsuite Unit
```
If a database is configured and the engelsystem is allowed to mess around with some files, you can run feature tests.
The tests can potentially delete some database entries, so they should never be run on a production system!
```bash
vendor/bin/phpunit --testsuite Feature
# or for unit- and feature tests:
vendor/bin/phpunit
```
To run code coverage reports its highly recommended to use [`pcov`](https://github.com/krakjoe/pcov) or at least `phpdbg -qrr`(which has problems with switch case statements) as using Xdebug slows down execution.
```bash
php -d pcov.enabled=1 vendor/bin/phpunit --testsuite Unit --coverage-text
```
### CI & Build Pipeline
The engelsystem can be tested and automatically deployed to a testing/staging/production environment.
2019-07-21 04:13:31 +02:00
This functionality requires a [GitLab](https://about.gitlab.com/) server with a working docker runner.
To use the deployment features the following secret variables need to be defined (if undefined the step will be skipped):
```bash
SSH_PRIVATE_KEY # The ssh private key
STAGING_REMOTE # The staging server, e.g. user@remote.host
STAGING_REMOTE_PATH # The path on the remote server, e.g. /var/www/engelsystem
PRODUCTION_REMOTE # Same as STAGING_REMOTE but for the production environment
PRODUCTION_REMOTE_PATH # Same as STAGING_REMOTE_PATH but for the production environment
```
2019-10-14 23:36:26 +02:00
### Docker
#### Production
To build the `es_nginx` and the `es_php_fpm` containers:
```bash
cd docker
docker-compose build
```
or to build the containers separately
```bash
2019-10-14 23:36:26 +02:00
docker build -f docker/nginx/Dockerfile . -t es_nginx
docker build -f docker/Dockerfile . -t es_php_fpm
```
Import database
```bash
2019-10-14 23:36:26 +02:00
docker exec -it engelsystem_es_php_fpm_1 bin/migrate
```
#### Development
This repo [ships a docker setup](docker/dev) for a quick development start.
If you use another uid/gid than 1000 on your machine you have to adjust it in [docker/dev/.env](docker/dev/.env).
Run this once
```bash
cd docker/dev
docker-compose up
```
Run these commands once initially and then as required after changes
```bash
2019-10-14 23:36:26 +02:00
# Install composer dependencies
docker exec -it engelsystem_dev_es_workspace_1 composer i
# Install node packages
docker exec -it engelsystem_dev_es_workspace_1 yarn install
# Run a front-end build
docker exec -it engelsystem_dev_es_workspace_1 yarn build
2019-10-14 23:36:26 +02:00
# Update the translation files
docker exec -it engelsystem_dev_es_workspace_1 find /var/www/resources/lang -type f -name '*.po' -exec sh -c 'file="{}"; msgfmt "${file%.*}.po" -o "${file%.*}.mo"' \;
# Run the migrations
docker exec -it engelsystem_dev_es_workspace_1 bin/migrate
```
2019-10-14 23:36:26 +02:00
While developing you may use the watch mode to rebuild the system on changes
```bash
2019-10-14 23:36:26 +02:00
# Run a front-end build
docker exec -it engelsystem_dev_es_workspace_1 yarn build:watch
```
##### Hint for using Xdebug with *PhpStorm*
For some reason *PhpStorm* is unable to detect the server name.
But without a server name it's impossible to set up path mappings.
Because of that the docker setup sets the server name *engelsystem*.
To get Xdebug working you have to create a server with the name *engelsystem* manually.
2018-08-07 16:47:47 +02:00
#### Scripts
2019-10-14 23:36:26 +02:00
2018-08-07 16:47:47 +02:00
##### bin/deploy.sh
The `bin/deploy.sh` script can be used to deploy the engelsystem. It uses rsync to deploy the application to a server over ssh.
2018-08-07 16:47:47 +02:00
For usage see `./bin/deploy.sh -h`
##### bin/migrate
The `bin/migrate` script can be used to import and update the database of the engelsystem.
2018-09-03 21:56:49 +02:00
For more information on how to use it call `./bin/migrate help`
2019-05-05 15:50:23 +02:00
### Translation
We use gettext. You may use POEdit to extract new texts from the sourcecode. Please config POEdit to extract also the twig template files using the following settings: https://gist.github.com/jlambe/a868d9b63d70902a12254ce47069d0e6
2019-11-10 23:26:23 +01:00
### Code style
2019-11-12 22:24:26 +01:00
Please ensure that your pull requests follow the [PSR-12](https://www.php-fig.org/psr/psr-12/) coding style guide.
2019-11-10 23:26:23 +01:00
You can check that by running
```bash
2019-11-12 22:24:26 +01:00
composer run phpcs
```
You may auto fix reported issues by running
```bash
2019-11-12 22:24:26 +01:00
composer run phpcbf
2019-11-10 23:26:23 +01:00
```