Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Fixtures Bundle Laravel Package

atournayre/fixtures-bundle

View on GitHub
Deep Wiki
Context7

Atournayre Fixtures Bundle

This bundle helps creating fixtures (with Alice).

Requirements

Symfony 6.2.*

PHP >=8.2

Install

Use Composer to install the package:

Composer

composer require atournayre/fixtures-bundle --dev

Register bundle

// config/bundles.php

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

Features

Command to load fixtures:

php bin/console fixtures

Events:

  • BeforeFixturesEvent
  • AfterFixturesEvent

Providers:

  • DateTime
  • Entity
  • Uuid
  • Hash password

Examples

Fixtures

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)>'

Events

Documentation : https://symfony.com/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    
    }
}

Contribute

Contributions to the package are always welcome!

License

All contents of this package are licensed under the MIT license.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui