atournayre/fixtures-bundle

此包最新版本(0.2.0)没有提供许可证信息。

配置文件包

安装: 63

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

0.2.0 2024-03-03 10:32 UTC

This package is auto-updated.

Last update: 2024-09-03 11:29:51 UTC


README

此包帮助使用Alice创建配置文件。

要求

Symfony 6.2.*

PHP >=8.2

安装

使用 Composer 安装此包

Composer

composer require atournayre/fixtures-bundle --dev

注册包

// config/bundles.php

return [
    // ...
    Hautelook\AliceBundle\HautelookAliceBundle::class => ['dev' => true, 'test' => true],
    Atournayre\Bundle\FixtureBundle\AtournayreFixtureBundle::class => ['dev' => true, 'test' => true],
    // ...
]

特性

加载配置文件的命令

php bin/console fixtures

事件

  • BeforeFixturesEvent
  • AfterFixturesEvent

提供者

  • DateTime
  • 实体
  • Uuid
  • 哈希密码

示例

配置文件

App\Entity\User:
  admin:
    # id: '<uuidV1()>'
    id: '<uuidV4()>'
    # id: '<uuidV6()>'
    # id: '<uuidV7()>'
    # id: '<uuidV8(uuid)>'
    email: 'admin@example.com'
    password: '<hashPassword(super_password)>'
    # The current date with specific time
    dateTime: '<currentDateWithTime(09:10)>'
    # The current date with random hour
    otherDateTime: '<randomHourWithDate()>'
    # A related entity identified by its id
    relatedEntity: '<entity<1, App\Entity\RelatedEntity)>'
    # A related entity identified by its uuid
    otherRelatedEntity: '<entity<b8ecc665-0d81-4a09-8ede-2c23a4355836, App\Entity\RelatedEntity)>'

事件

文档: https://symfony.com.cn/doc/current/event_dispatcher.html#defining-event-listeners-with-php-attributes

<?php
namespace App\Listener;

use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Atournayre\Bundle\FixtureBundle\Event\AfterFixturesEvent;

#[AsEventListener]
readonly class AfterFixtureListener
{
    public function __invoke(AfterFixturesEvent $event): void
    {
        // Your code    
    }
}

贡献

欢迎对包的贡献!

许可证

本包所有内容均受 MIT许可证 授权。