barlito/utils 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

barlito/utils

最新稳定版本:v2.0.0

Composer 安装命令:

composer require barlito/utils

包简介

My personal library of utilities

README 文档

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, ...).

统计信息

  • 总下载量: 246
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: mit
  • 更新时间: 2022-05-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固