PHPackages                             j-ben87/data-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. j-ben87/data-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

j-ben87/data-bundle
===================

Allow to load fixtures datasets through command line.

1.2.1(8y ago)14.5k1MITPHPPHP &gt;=5.5.9

Since Jun 24Pushed 8y ago3 watchersCompare

[ Source](https://github.com/J-Ben87/DataBundle)[ Packagist](https://packagist.org/packages/j-ben87/data-bundle)[ RSS](/packages/j-ben87-data-bundle/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

DataBundle
==========

[](#databundle)

Installation
------------

[](#installation)

Install with composer:

```
composer require j-ben87/data-bundle
```

Register the bundle in your `app/AppKernel.php`:

```
public function registerBundles()
{
    $bundles = [
        // ...
        new JBen87\DataBundle\DataBundle(),
    ];

    // ...
}
```

Configuration
-------------

[](#configuration)

The bundle exposes the following configuration:

```
# app/config/config.yml
data:
    culture: fr_FR                                      # required - used to generate localized data with Faker
    fixtures_dir: "%kernel.root_dir%/data/fixtures"     # default value - directory where datasets fixtures files are located
    datasets:
        fake:
            files:
                - "user.yml"
                - "address.yml"
            processors:                                 # optional - white list some processors (default to all if empty)
                - "@app.data_fixtures.processor.user"
            providers:                                  # optional - white list some providers (default to all if empty)
        other:
            files:
                - "..."
```

Basic usage
-----------

[](#basic-usage)

### Command

[](#command)

The bundle provides a command similar to [DoctrineFixturesBundle](https://github.com/doctrine/DoctrineFixturesBundle) to load your fixtures using [Alice](https://github.com/nelmio/alice) and [Faker](https://github.com/fzaninotto/Faker).

```
Usage:
  bin/console data:fixtures:load  [options]

Arguments:
  dataset                    The dataset to load.

Options:
      --append               Append the data fixtures instead of deleting all data from the database first.
      --purge-with-truncate  Purge data by using a database-level TRUNCATE statement
```

### Dataset

[](#dataset)

To load your fixtures, you first need to create a **dataset**.

A dataset is made of two things:

- a directory containing `yml` fixtures files that will be loaded by [Alice](https://github.com/nelmio/alice)
- a `Dataset` service referencing the files to load (order matters)

Note: if you use configuration to define your datasets, the `Dataset` service will be automatically handled for you.

#### Defintion

[](#defintion)

All you need to do is to list the fixtures files to load in the configuration in the order you want them to be processed.

```
# app/config/config.yml
data:
    datasets:
        fake:
            files:
                - "user.yml"
                - "..."
```

#### Fixtures files

[](#fixtures-files)

By default, the files containing the datasets fixtures are located in `app/data/fixtures` but [this can be configured](#configuration).

```
# app/data/fixtures/fake/user.yml
AppBundle\Entity\User:
    user_{1..10}:
        firstname:
        lastname:
        email:
        password:
```

That's it, you are ready to go!

Advanced usage
--------------

[](#advanced-usage)

### Providers &amp; Processors

[](#providers--processors)

[Alice](https://github.com/nelmio/alice) comes with [Providers](https://github.com/nelmio/alice/blob/2.x/doc/customizing-data-generation.md#custom-faker-data-providers) and [Processors](https://github.com/nelmio/alice/blob/2.x/doc/processors.md).

You can register yours with the command the same way you registered a `Dataset`:

- providers must be tagged with `data.provider`
- processors must be tagged with `data.processor`

```
services:
    app.data_fixtures.provider.custom:
        class: AppBundle\DataFixtures\Provider\CustomProvider
        public: false
        tags:
            - { name: data.provider }

    app.data_fixtures.processor.user:
        class: AppBundle\DataFixtures\Processor\User
        public: false
        tags:
            - { name: data.processor }
```

They will automatically be available and used to write your fixtures and process them.

*Note: you can white list some providers or processors for a dataset in the [configuration](#configuration).*

### Datasets

[](#datasets)

If you can't or don't want to use configuration to define your datasets, you can also create them manually.

Create a `Dataset` class somewhere in your project. It must implement `JBen87\DataBundle\Dataset\DatasetInterface`. Alternatively it can also extend the base class `JBen87\DataBundle\Dataset\Dataset`.

```
// src/AppBundle/DataFixtures/Dataset/FakeDataset.php

use JBen87\DataBundle\Dataset\Dataset;

class FakeDataset extends Dataset
{
    /**
     * @inheritDoc
     */
    public function getFiles()
    {
        return [
            'user.yml',
        ];
    }
}
```

To be registered with the command, it must also be declared as a service with the tag `data.dataset`. Optional tag attribute `alias` can be used to set the dataset name.

**Important:** if not provided, the dataset name is guessed from the service id (e.g. the name for the service `app.data_fixtures.dataset.fake` will be `fake`).

```
services:
    app.data_fixtures.dataset.fake:
        class: AppBundle\DataFixtures\Dataset\FakeDataset
        public: false
        tags:
            - { name: data.dataset }
```

Contributing
------------

[](#contributing)

Pull requests are welcome.

Thanks to [everyone who has contributed](https://github.com/J-Ben87/DataBundle/graphs/contributors) already.

---

Released under the MIT License

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~193 days

Total

4

Last Release

3125d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e229e02c5eca6d2ea70e3e40bdd2f9e0136fc6f2428397fe05a45b2ec78efe9a?d=identicon)[J-Ben87](/maintainers/J-Ben87)

---

Top Contributors

[![J-Ben87](https://avatars.githubusercontent.com/u/1433301?v=4)](https://github.com/J-Ben87 "J-Ben87 (15 commits)")

---

Tags

symfonybundlefixturesdatadoctrine

### Embed Badge

![Health badge](/badges/j-ben87-data-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/j-ben87-data-bundle/health.svg)](https://phpackages.com/packages/j-ben87-data-bundle)
```

###  Alternatives

[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46118.4M173](/packages/sonata-project-doctrine-orm-admin-bundle)[omines/datatables-bundle

Symfony DataTables Bundle with native Doctrine ORM, Elastica and MongoDB support

2841.5M6](/packages/omines-datatables-bundle)[okapon/doctrine-set-type-bundle

Provides support of MySQL SET type for Doctrine2 in Symfony2 applications.

12160.9k](/packages/okapon-doctrine-set-type-bundle)[prezent/doctrine-translatable-bundle

Integrate the doctrine-translatable extension in Symfony

14745.6k7](/packages/prezent-doctrine-translatable-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
