miaou-corp / fixture-loader-bundle
Manage Nelmio Alice fixtures with Doctrine.
Installs: 324
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/miaou-corp/fixture-loader-bundle
Requires
- php: >=7.1.0
- nelmio/alice: ^3.2
- symfony/finder: ~2.8|~3.0|~4.0
Requires (Dev)
- doctrine/orm: ^2.4
- symfony/config: ~2.8|~3.0|~4.0
- symfony/dependency-injection: ~2.8|~3.0|~4.0
- symfony/http-kernel: ~2.8|~3.0|~4.0
- symfony/phpunit-bridge: ^4.0
This package is not auto-updated.
Last update: 2026-02-06 14:10:54 UTC
README
This bundle use Nelmio/Alice for fixture generation.
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
$ composer require --dev miaou-corp/fixture-loader-bundle
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require --dev miaou-corp/fixture-loader-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
//...
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
//...
$bundles[] = new Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle();
$bundles[] = new MiaouCorp\Bundle\FixtureLoaderBundle\MiaouCorpFixtureLoaderBundle();
}
}
// ...
}
Step 3: Configure the bundle
# config_test.yml
# Do not use production database !
# SQLite in memory is recommended for tests speed.
doctrine:
dbal:
url: 'sqlite:///:memory:'
miaoucorp_fixture_loader:
# This is where you fixture files are stored.
directory: /path/to/directory # Default to: '%kernel.project_dir%/tests/Resources/fixtures'
Important note: Each time you load a fixture file, the database schema is drop and rebuilt, so do not use in production...
Usage
Inside a WebTestCase:
$client = static::createClient();
// You might want to do this if you do multiple request on a single test
// As kernel is rebooted on each request, so your database and fixtures will be lost.
$client->disableReboot();
// Or static::$kernel->getContainer for a KernelTestCase
$client->getContainer()->get('miaoucorp.fixture_loader')->loadFile('my-fixture-file.yaml');
$client->request('GET', '/some-path');
// To keep some fixture in memory for later use:
// Where "user_1" is the fixture key.
$fixtures = $client->getContainer()->get('miaoucorp.fixture_loader')
->loadFile('my-fixture-file.yaml', ['user_1']);
$userId = $fixtures['user_1']->getId();