Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

AliceDataFixtures

> 数据库
Open source

Nelmio Alice extension to persist the loaded fixtures.

322 stars0 likes0 views
WebsiteGitHub

About

Nelmio Alice extension to persist the loaded fixtures.

AliceDataFixtures

Alice 3.x no longer ships with a persistence layer, so this library provides one! Supports:

  • Symfony 7.4+
  • Doctrine ORM 3.3+
  • Doctrine ODM 5.1+
  • Doctrine PHPCR 2.0+
  • Eloquent 12.0+

Documentation

  1. Installation
    1. Without Symfony
    2. Symfony with Flex
    3. Symfony without flex
      1. Doctrine ORM
      2. Doctrine ODM
      3. Doctrine PHPCR
      4. Eloquent ORM
      5. Configuration
  2. Basic usage
  3. Configuration
  4. Advanced usage
    1. Processors
    2. Exclude tables from purge
    3. Usage in tests
      1. PHPUnit
      2. Behat
  5. Contributing

Configuration

The full configuration reference is:

yaml
# app/config/config.yml

# Default config
fidry_alice_data_fixtures:
    default_purge_mode: ~ # default is "delete" but you can change it to "truncate" or "no_purge"
    db_drivers:
        doctrine_orm: ~
        doctrine_mongodb_odm: ~
        doctrine_phpcr_odm: ~
        eloquent_orm: ~

For each driver, if the appropriate bundle is detected, e.g. DoctrineORMBundle for Doctrine and WouterJEloquentBundle for Eloquent, the services related to those driver will be enabled. If you want to skip those checks you can turn a specific driver to true instead. If you want to disable a specific driver, simply force the value false instead.

Basic usage

Create a fixture file in src/AppBundle/Resources/fixtures:

yaml
# src/AppBundle/Resources/fixtures/dummy.yml

AppBundle\Entity\Dummy:
    dummy_{1..10}:
        name: 
        related_dummy: '@related_dummy*'
yaml
# src/AppBundle/Resources/fixtures/related_dummy.yml

AppBundle\Entity\RelatedDummy:
    related_dummy_{1..10}:
        name: 

Then you can load those files using a LoaderInterface:

php
get('fidry_alice_data_fixtures.loader.doctrine');         // For Doctrine ORM
$loader = $container->get('fidry_alice_data_fixtures.loader.doctrine_mongodb'); // For Doctrine MongoDB ODM
$loader = $container->get('fidry_alice_data_fixtures.loader.doctrine_phpcr');   // For Doctrine PHPCR
$loader = $container->get('fidry_alice_data_fixtures.loader.eloquent');         // For Eloquent ORM

// Purge the objects, create PHP objects from the fixture files and persist them
$objects = $loader->load($files);

// $objects is now an array of persisted `Dummy` and `RelatedDummy`

Warning: loading the objects does not trigger a clear(). This means if you are relying on some Doctrine life-cycle events in your tests, some may not be triggered as expected. See #84 For more information.

Advanced Usage

Check the advance usage entry.

Contributing

Clone the project

To launch Docker containers for databases, run make start_databases

Run tests with make test.

To stop containers for databases, run make stop_databases

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPalicedatabasefixturesmanage-fixtures

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库