barlito / utils
My personal library of utilities
v2.0.0
2026-06-09 16:58 UTC
Requires
- php: >=8.4
- doctrine/orm: ^3
- gedmo/doctrine-extensions: ^3.8
- symfony/doctrine-bridge: ^7.0 || ^8.0
- symfony/framework-bundle: ^7.0 || ^8.0
- symfony/property-access: ^7.0 || ^8.0
- symfony/serializer: ^7.0 || ^8.0
- symfony/uid: ^7.0 || ^8.0
- symfony/validator: ^7.0 || ^8.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.9
- behat/behat: ^3.13
- friendsofphp/php-cs-fixer: ^3.92
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.2
- phpstan/phpstan-doctrine: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11 || ^12
- rector/rector: ^2.4
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^4.0
README
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 withLoggerMock, 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):
PHPStan — phpstan.dist.neon:
includes: - vendor/barlito/utils/config/phpstan.neon parameters: paths: - src
Rector — rector.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, ...).