-
-
Notifications
You must be signed in to change notification settings - Fork 4
How to set up Scrutinizer
Scruitinizer is a continuous inspection platform to continuously measure and track code quality.
Below is a guide on how to set up Scrutinizer for PHP projects with this
Configuration structure of
the slim-example-project
,
slim-api-starter
and the
slim-starter
project templates.
The database name and credentials used by Scrutinizer must be
set in the config/env/env.scrutinizer.php
file.
File: config/env/env.scrutinizer.php
<?php
// Include testing configuration. Must be "require" and not require_once
require __DIR__ . '/env.test.php';
// Database
$settings['db']['host'] = '127.0.0.1';
$settings['db']['database'] = 'slim_example_project_test'; // replace with your test database name
$settings['db']['username'] = 'root';
$settings['db']['password'] = '';
The .scrutinizer.yml
file (below) sets the APP_ENV
to 'scrutinizer' which means that
the env.scrutinizer.php
file will be loaded when
building the settings array
in config/settings.php
.
The Scrutinizer settings file .scrutinizer.yml
stored in the project root folder
defines the build configuration.
Replace the database name with the name of your test database as specified in config/env/env.scrutinizer.php
.
File: .scrutinizer.yml
filter:
paths: [ "src/*" ]
excluded_paths: [ "vendor/*", "tests/*", "resources/", "public/", ]
checks:
php:
code_rating: true
duplication: true
tools:
external_code_coverage: false
build:
services:
mysql: 8.0.29
environment:
php:
version: 8.2
ini:
xdebug.mode: coverage
mysql: 5.7
node: false
postgresql: false
mongodb: false
elasticsearch: false
redis: false
memcached: false
neo4j: false
rabbitmq: false
variables:
APP_ENV: 'scrutinizer'
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
dependencies:
before:
- composer self-update
- mysql -uroot -e "CREATE DATABASE IF NOT EXISTS slim_example_project_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
tests:
before:
- command: composer test:coverage
coverage:
file: 'build/logs/clover.xml'
format: 'clover'
The composer test:coverage
shortcut command has to be defined in the
scripts
section
of the composer.json
file with the coverage report path matching the one
defined in the Scrutinizer settings above.
Now this file can be pushed to the remote repository and the project registered on the Scrutinizer website.
- Create an account.
- Add your repository by following the instructions on the website.
Slim app basics
- Composer
- Web Server config and Bootstrapping
- Dependency Injection
- Configuration
- Routing
- Middleware
- Architecture
- Single Responsibility Principle
- Action
- Domain
- Repository and Query Builder
Features
- Logging
- Validation
- Session and Flash
- Authentication
- Authorization
- Translations
- Mailing
- Console commands
- Database migrations
- Error handling
- Security
- API endpoint
- GitHub Actions
- Scrutinizer
- Coding standards fixer
- PHPStan static code analysis
Testing
Frontend
Other