- PHP 7.4 or higher
- PostgreSQL 12.1 or higher
- PHP extensions:
- Ctype
- iconv
- JSON
- PCRE
- Session
- SimpleXML
- Tokenizer
- Docker
- Docker-Compose
- Free ports on host as defined in
.env
- Clone this repository:
$ git clone [email protected]:thled/thled_bugtracker.git
- Change to project directory:
$ cd thled_bugtracker
- Copy .env for Docker-Compose:
$ cp .env.dist .env
- Build and start the docker containers:
$ docker-compose up -d
- Initialize the app:
$ docker-compose exec app composer bootstrap
- Access the application:
localhost:80
- SSH into container:
$ docker-compose exec app bash
- SSH into node container for using Yarn:
$ docker-compose exec frontend ash
- Manage DB with Adminer:
localhost:8080
- System:
PostgreSQL
- Server:
db
- Username:
db
- Password:
db
- Database:
db
- System:
- Receive mails with Mailcatcher:
http://localhost:1080
- Debug with xDebug:
- Maybe adjust local IP of host with
xdebug.remote_host
indocker/php/xdebug.ini
- Vim configuration:
- Use Vdebug Plugin from
vim-vdebug/vdebug
- Copy local rc file:
$ cp .nvimrc.dist .nvimrc
- Change second part of
path_maps
to the project on host in.nvimrc
- Use Vdebug Plugin from
- PHPStorm configuration:
- Change debug port under
Settings/Languages/PHP/Debug
to9001
- Add new server under
Settings/Languages/PHP/Servers
- Name:
docker-server
- Host:
localhost
- Port:
80
- Debugger:
Xdebug
- Select "Use path mappings" and map "Project files" to
/usr/src/app
- Name:
- Change debug port under
- Start "Listening for PHP Debug Connections"
- Maybe adjust local IP of host with
- Lint with CodeSniffer:
- PHPStorm configuration:
- Set path to script under
Settings/Languages/PHP/Quality_Tools/PHP_CodeSniffer
topath/to/project/app/scripts/phpcs.sh
- Activate "PHP_CodeSniffer validation" under
Settings/Editor/Inspections/PHP/Quality_tools
- Set path to script under
- PHPStorm configuration:
To ensure a high quality of the code base different tools are used to analyse, lint and fix code which does not adhere to the standards (PSR, Symfony etc.). There are manual tools and automatic tools for this purpose. Manual tools should be executed regularly while developing and automatic tools are executed in the Github Actions Workflow (alias Pipeline) or externally (e.g. SonarQube/SonarCloud).
- PHP Code Beautifier and Fixer:
$ composer fix
- PHPStan:
$ composer analyse
- PHP_CodeSniffer:
$ composer lint
- SonarCloud (triggered by pushing to Master branch)
- Codecov (triggered by pushing)
This project uses a custom workflow named "THlEd-FLOW" which is based on "GitHub flow".
- Run whole test suite:
$ composer tests
- Run unit tests:
$ composer unit
- Run integration tests:
$ composer integration
- Run functional tests:
$ composer functional
- Run code coverage:
$ composer code-coverage
(then openapp/coverage/index.html
)
- PHPUnit is used as testing framework.
- Prophecy is used as object mocking framework.
- There are three types of tests:
- Unit Tests: Testing methods in isolation. (E.g. Service classes)
- Integration Tests: Testing modules without stubbing/mocking dependencies like a database. (E.g. Repository classes)
- Functional Tests: Testing frontend behavior. (E.g. Controller classes)
- Seek for high code coverage (>90%).
- Every test must have a
@covers
annotation for the class it covers to not accidentally cover classes which are not under test. - Code coverage should be reached by Unit Tests. Exceptions are Controllers and Repositories which are tested by Functional Tests and Integration Tests respectively.
- Do not test private/protected methods explicitly.
- Do not test objects which have no logic like Entities and Models/DTOs.
- Do not test code which will not run in production like DataFixtures.
- It is not necessary to stub/mock third party libraries and objects without logic like the ones mentioned before.
Please do contribute! Issues and pull requests are welcome.