Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

 

History

History
86 lines (61 loc) · 2.15 KB

File metadata and controls

86 lines (61 loc) · 2.15 KB

Installation

Prerequisites

This bundle requires Symfony 2.1+

Installation

  1. Download SpFixtureDumperBundle using composer
  2. Enable the Bundle
  3. Dump fixtures from database

Step 1: Download SpFixtureDumperBundle using composer

Add SpFixtureDumperBundle in your composer.json:

{
    "require": {
        "sp/fixture-dumper-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:

php composer.phar update sp/fixture-dumper-bundle

Composer will install the bundle to your project's vendor/sp directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Sp\FixtureDumperBundle\SpFixtureDumperBundle(),
    );
}

Step 3: Dump fixtures from doctrine

You can dump fixtures from existing entities via the command

php app/console sp:fixture-dumper:orm /path/to/fixtures

If you're using the ODM, use the sp:fixture-dumper:mongodb command instead:

php app/console sp:fixture-dumper:mongodb /path/to/fixtures

Both commands come with a few options:

  • --format=yml - Use this option to manually specify the format for the dumped fixtures. There are currently three implemented

    • class (default) - Dump class fixtures
    • yml - Dump yml fixtures which can be loaded with the alice library
    • array - Dump php array fixtures which can be loaded with the alice library
  • --single-file - Use this flag to dump all fixtures into one file

  • --em=manager_name - Manually specify the entity manager to use for loading the data.

Note: If using the sp:fixture-dumper:mongodb task, replace the --em= option with --dm= to manually specify the document manager.

A full example use might look like this:

php app/console sp:fixture-dumper:orm --format=yml --single-file --em=foo_manager /path/to/fixtures