PHPackages                             gos/fixture - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. gos/fixture

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

gos/fixture
===========

Provide solution to process simple fixtures

0103PHP

Since Oct 1Pushed 11y ago1 watchersCompare

[ Source](https://github.com/GeniusesOfSymfony/Fixture)[ Packagist](https://packagist.org/packages/gos/fixture)[ RSS](/packages/gos-fixture/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

\#Gos Fixtures Component#

[![Build Status](https://camo.githubusercontent.com/34d7cd49faae280ec81adb57d5022929e061a893a11557b8e1358b96d39c7f92/68747470733a2f2f7472617669732d63692e6f72672f47656e69757365734f6653796d666f6e792f466978747572652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/GeniusesOfSymfony/Fixture) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/fe87769fcbc9384314378f04bd5aac60404893995f72809a6c340b9ae8938c0b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f47656e69757365734f6653796d666f6e792f466978747572652f6261646765732f7175616c6974792d73636f72652e706e673f733d63643831623839303465613465376665643138646361396638313861373063393563643536303966)](https://scrutinizer-ci.com/g/GeniusesOfSymfony/Fixture/) [![Code Coverage](https://camo.githubusercontent.com/0d614f85671ba634cf23cca635e4520945fdaa3cf84e32ebf63061d58c22a264/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f47656e69757365734f6653796d666f6e792f466978747572652f6261646765732f636f7665726167652e706e673f733d31323139366630626266633164663739336335306133656365386237663834383764663737346230)](https://scrutinizer-ci.com/g/GeniusesOfSymfony/Fixture/) [![SensioLabsInsight](https://camo.githubusercontent.com/30246169f9f75b0a98b01f4ca683ef3bb39ba9e9fe214ce7b11a1aca2d840cc3/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f62653933336438372d373837662d346134312d393439642d3635653031656235623566372f6d696e692e706e67)](https://insight.sensiolabs.com/projects/be933d87-787f-4a41-949d-65e01eb5b5f7)

**This project is currently in development, so please take care.**

Create fixture can be painful mainly when you write them for little entity.You would create them faster as possible and with specific values.

Here an example from doctrine-data-fixture.

```
namespace MyDataFixtures;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;

class LoadUserRoleData extends AbstractFixture
{
    public function load(ObjectManager $manager)
    {
        $adminRole = new Role();
        $adminRole->setName('admin');

        $anonymousRole = new Role;
        $anonymousRole->setName('anonymous');

        $manager->persist($adminRole);
        $manager->persist($anonymousRole);
        $manager->flush();

        // store reference to admin role for User relation to Role
        $this->addReference('admin-role', $adminRole);
    }
}
```

If you hate store data in php array and dont want take time to create a dedicated component, it's for you. Store their in YAML file and fetch easily your data !

How to use
----------

[](#how-to-use)

```
namespace MyDataFixtures;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\Persistence\ObjectManager;

class LoadUserRoleData extends AbstractFixture
{
    public function load(ObjectManager $manager)
    {
    	//Instanciate the fixture component with the path of folder who contains our YAML data fixture
        //File are retrieve via Symfony Finder Component, so your do path/*/*/folder and all think who is
        //interpreted by the finder
        $fixture = new Fixture('path/to/my/fixture/folder', $this);

        //If you want split / order your fixture you can also add dynamically some folder
        $this->fixture->addDirectory('path/to/my/fixture/another_folder');

        //Now load your specific file
        $fixture->load('myDataFixture.yml');

        //And now you can fetch your data
        foreach($this->fixture->fetch() as $data){
        	//attach to your entity with PropertyAccess or by the hand.
        }

    }
}
```

Here an example of YAML data :

```
database:
    name:
        - 'fr'
        - 'en'
        - 'it'
        - 'es'
    locale:
        - 'fr_FR'
        - 'en_US'
        - 'it_IT'
        - 'es_ES'
    status:
        - 'active'
        - 'active'
        - 'active'
        - 'inactive'
    default:
        - true
```

\####Handle one to many with ArrayCollection####

```
collection:
    scope: [ "roles" ]
database:
	username:
    	- 'alice'
        - 'bob'
        - 'peter'
    roles: #this is a one to Many
        - 'client'
        - 'editor'
        - 'admin'
```

\####Retrieve reference####

```
database:
	user:
    	- &alice
```

Roadmap
-------

[](#roadmap)

Actually this component not cover all features you can meet. You can't create reference from YAML, and collection are not fully supported, currently they just convert array into ArrayCollection because we dont have meet this use case at this time, but it's we will, so we plan.

\[\] Generate reference directly from YAML \[\] Fully support for Collection

Concret example
---------------

[](#concret-example)

```
public function load(ObjectManager $manager)
{
    $fixture = new Fixture('src/*/*/DataFixtures/YML/');
    $this->localeManager = $this->container->get('gos.i18n_bundle.locale_entity.manager');

    $this->fixture->load('LocaleData.yml', $this);

    foreach ($this->fixture->fetch() as $data) {
        $locale = $this->localeManager->create($data);
        $this->setReference($locale->getName(), $locale);
    }

    $this->localeManager->save();
}
```

You can also see :
------------------

[](#you-can-also-see-)

- [Fixture Bundle version for Symfony2](https://github.com/GeniusesOfSymfony/FixtureBundle)
- [Doctrine Data Fixture](https://github.com/doctrine/data-fixtures)
- [Doctrine Fixtures Bundles](https://github.com/doctrine/DoctrineFixturesBundle)

Running the tests
-----------------

[](#running-the-tests)

PHPUnit 3.5 or newer together with Mock\_Object package is required. To setup and run tests follow these steps:

- go to the root directory of the project
- run: composer install --dev
- run: phpunit

License
-------

[](#license)

The project is under MIT lisence, for more information see the LICENSE file inside the project

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2697e85bca7c41cb6166cf78dca3156bdbbe7950189f0b958115201dcd9a919a?d=identicon)[ProPheT777](/maintainers/ProPheT777)

### Embed Badge

![Health badge](/badges/gos-fixture/health.svg)

```
[![Health](https://phpackages.com/badges/gos-fixture/health.svg)](https://phpackages.com/packages/gos-fixture)
```

###  Alternatives

[humanmade/hm-rewrite

HM\_Rewrite is a wrapper for the WordPress WP Rewrite system. http://hmn.md/wordpress-rewrite-rules-hm-core-style/

16115.9k](/packages/humanmade-hm-rewrite)

PHPackages © 2026

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