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.
- Zero config, easy to use
- Faker method selection based on entities attributes
- Handling of associations
- Fixtures order based on association dependencies
- For Symfony 4+
Open a command console, enter your project directory and execute:
$ composer require gsylvestre/symfony-faker-fixtures
-
Generate your new fixture command with:
$ php bin/console make:faker-fixtures
-
Load magic datas in your database with:
$ php bin/console app:fixtures:load
This bundle generates fixtures for you. Once done, you are free to edit them.
If needed (and it should), edit the generated FakerFixturesCommand.php
:
- To adapt the number of entities to generate, or the order
- To adapt the Faker methods used and/or the logic
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!
If you want your generated datas localized, run:
$ php bin/console make:faker-fixtures --locale=fr_FR
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.
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(),
];
// ...
}
// ...
}
This bundle deliberately does not use DoctrineFixturesBundle in any way.