Skip to main content

Janus PHP

Janus is a library to provide the config for our CI / code style tools.

We use the following tools:

The philosophy of this library is like this:

  1. put reusable config into the library
  2. place all config files in the root of the project, but reference the reusable config files from the library

This has the following advantages: every developer and tool detects that we use these tools, but we have a reusable config that can be automatically update with a composer update.

All tools are installed and used with the Composer bin plugin, so that the dependencies don't interfere with your application.

tip

If you want to use PHPUnit, please make sure the read the note about it.

Installation

Install the library with:

composer req --dev 21torr/janus

Integration

To place the import files into the project, the library provides a helper that just copies the files to the repository and updates the composer.json. So make sure that your Git is clean before running this command. After updating, you can diff and integrate the changes with git.

You have several options:

# Initialize in a symfony application
./vendor/bin/janus init-symfony

# Initialize in a library
./vendor/bin/janus init-library

Usage

Janus also adds scripts to your composer.json that you then run with composer:

# Fixes lint issues
composer run-script fix-lint

# Runs linting, use in your CI
composer run-script lint

# Runs tests, use in your CI
composer run-script test

Integration in CI

Your CI should just use the composer scripts:

.gitlab-ci.yml
"Build App":
script:
- "composer install --optimize-autoloader --classmap-authoritative --no-interaction"
- "composer run-script lint"
- "composer run-script test"

BC Promise

This package has by definition no BC promise. So with every update it is possible, that your CI will fail.

However, that is intended: the whole purpose of this package is to force the application to have clean, error-free and clearly structured code. So forcing the dev to be always up-to-date is a good thing.

PHP CS Fixer

We use our own PHP-CS-Fixer package, as it adds custom configuration for our usage.