mrjoops/symfony-service-devtools

A set of useful tools for building Symfony services.

v0.4.0 2019-09-03 11:23 UTC

This package is auto-updated.

Last update: 2024-04-27 23:03:10 UTC


README

A set of useful tools for building Symfony services. To date, it includes:

Installation

You can install it with Composer.

composer config extra.symfony.allow-contrib true
composer require --dev mrjoops/symfony-service-devtools

Prerequisites

Although both are optional, please ensure you have installed docker-compose alongside Docker on your system.

If you use Symfony Flex, you can safely jump to the Usage section. Otherwise you must copy the following files in your project to enjoy all the features:

  • .env.test
  • .php_cs.dist
  • bitbucket-pipelines.yml
  • docker-compose.yml
  • Dockerfile
  • dredd.yml
  • Makefile
  • phpcs.xml.dist
  • phpmd.xml
  • phpstan.neon.dist
  • phpunit.xml.dist
cp vendor/mrjoops/symfony-service-devtools/{.env.test,.php_cs.dist,bitbucket-pipelines.yml,docker-compose.yml,Dockerfile,dredd.yml,Makefile,phpcs.xml.dist,phpmd.xml,phpstan.neon.dist,phpunit.xml.dist} .

Don't forget to add the following lines in your .gitignore file:

/.php_cs
/.php_cs.cache
/phpcs.xml
/.phpcs-cache
/phpstan.neon
/phpunit.xml
.phpunit.result.cache
/test-reports/
/vendor/

Feel free to edit these files to fit your needs.

Usage

Quality tools

You can run all the code quality tools with this command:

make check

You can run them individually:

make md
make sniff
make stan
make style

You can also run the fixers with this command:

make fix

And again, you can run them individualy:

make fix-sniff
make fix-style

Testing tools

You can run all the testing tools with this command:

make test

You can run them individually:

make dredd
make unit

A note about Dredd

Since Dredd is a NodeJS tool, it is not installed with mrjoops/symfony-service-devtools. However it is included in the Docker image (see below) and ready to go!

Docker

You can add services to the docker-compose.yml file. Then you can start your services with the following command:

docker-compose up -d

The base Docker image used here is mrjoops/ppm which uses PHP-PM, so you have an efficient PHP web server up and running!

Continuous integration

A configuration for Bitbucket Pipelines exists, it will run all checks and tests on pull requests.

Opinionated advices

  1. Do yourself a favor and create this alias: alias dk='docker-compose exec app' so you'll just have to prefix your commands with dk to have them executed in the container.
  2. It's a good idea to add make check (or dk make check) to your git workflow by creating a pre-commit hook.