Skip to content

Fast generation of realistic fake datas for your database. Symfony/Doctrine/Faker/Make super combo.

License

Notifications You must be signed in to change notification settings

gsylvestre/symfony-faker-fixtures

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Faker Fixtures Maker for Symfony

This bundle allows fast generation of realistic fake datas for your database, in the make style that we love. Huge thanks to the wonderfull Faker library.

Main features

  • Zero config, easy to use
  • Faker method selection based on entities attributes
  • Handling of associations
  • Fixtures order based on association dependencies
  • For Symfony 4+

Installation

Open a command console, enter your project directory and execute:

$ composer require gsylvestre/symfony-faker-fixtures

How to use

  1. Generate your new fixture command with:

    $ php bin/console make:faker-fixtures
  2. Load magic datas in your database with:

    $ php bin/console app:fixtures:load

Editing the fixtures

This bundle generates fixtures for you. Once done, you are free to edit them.

If needed (and it should), edit the generated FakerFixturesCommand.php:

  1. To adapt the number of entities to generate, or the order
  2. To adapt the Faker methods used and/or the logic

Start over?

If you ever need to regenerates all your fixtures, you can do so by running:

$ php bin/console make:faker-fixtures --delete-previous

Be aware that you will lose all changes made to your fixtures command!

Localize faker datas?

If you want your generated datas localized, run:

$ php bin/console make:faker-fixtures --locale=fr_FR

Installation without 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 gsylvestre/symfony-faker-fixtures

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()
    {
        $bundles = [
            // ...
            new FakerFixtures\FakerFixturesBundle(),
        ];

        // ...
    }

    // ...
}

Notes

This bundle deliberately does not use DoctrineFixturesBundle in any way.

About

Fast generation of realistic fake datas for your database. Symfony/Doctrine/Faker/Make super combo.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages