barlito/utils

My personal library of utilities

Maintainers

Package info

github.com/barlito/utils

pkg:composer/barlito/utils

Statistics

Installs: 365

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.0 2026-06-09 16:58 UTC

README

CI

Personal library of Symfony utilities: Doctrine ID traits and reusable Behat contexts.

Requirements

  • PHP >= 8.4
  • Symfony 7 or 8
  • Doctrine ORM 3

Installation

composer require barlito/utils

Usage

Doctrine ID traits

Add a UUID or ULID primary key to an entity (generated by the Symfony bridge generators):

use Barlito\Utils\Traits\IdUuidTrait; // or IdUlidTrait
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class MyEntity
{
    use IdUuidTrait;
}

Behat contexts

Register the contexts in your behat.yml suite and wire them as services:

  • Barlito\Utils\Behat\Component\EntityManagerContext — assert on database state:
Given a "User" entity found by "email=foo@bar.com" should match:
    | name | Foo |
Given a "User" entity found by "deletedAt:date=2024-01-01" should not exist
Given I should find 3 "User" entity found by "status=active"
Then I create a "User" entity with data:
    """
    {"email": "foo@bar.com"}
    """
  • Barlito\Utils\Behat\Component\LoggerContext + Barlito\Utils\Behat\Mock\LoggerMock — decorate the logger in test env with LoggerMock, then:
Then the logger logged the error with message "Something went wrong"
Then the logger logged an error containing "went wrong"

Reusable QA configs

The config/ directory ships ready-to-use QA configs for consuming projects (install the tools in your own require-dev):

PHPStanphpstan.dist.neon:

includes:
    - vendor/barlito/utils/config/phpstan.neon

parameters:
    paths:
        - src

Rectorrector.php:

$builder = require 'vendor/barlito/utils/config/rector.php';

return $builder
    ->withPaths([__DIR__ . '/src'])
    ->withCache(__DIR__ . '/var/cache/rector');

PHP-CS-Fixer — run with the shipped config (paths resolve from your project root):

vendor/bin/php-cs-fixer fix --config=vendor/barlito/utils/config/.php-cs-fixer.dist.php

PHPCS (PSR-12):

vendor/bin/phpcs --standard=vendor/barlito/utils/config/phpcs.xml.dist src

PHPMD:

vendor/bin/phpmd src text vendor/barlito/utils/config/phpmd.xml

Development

make deploy        # start the dev container
make phpstan       # static analysis (level 8)
make cs            # coding standards check (php-cs-fixer, @Symfony)
make cs-fix        # apply coding standards
make rector        # rector dry-run
make rector-fix    # apply rector rules
make phpcs         # PSR-12 check (phpcs)
make phpmd         # mess detection (phpmd, isolated via vendor-bin)
make qa            # run the whole QA suite

The same commands are available as composer scripts (composer phpstan, composer cs, composer rector, ...).