gsylvestre / symfony-faker-fixtures
Fast generation of realistic fake datas for your database. Symfony/Doctrine/Faker/Make super combo.
Package info
github.com/gsylvestre/symfony-faker-fixtures
Type:symfony-bundle
pkg:composer/gsylvestre/symfony-faker-fixtures
Requires
- php: ^7.1
- ext-mbstring: *
- fzaninotto/faker: 1.*
- symfony/config: ^4.0|^5.0
- symfony/console: ^4.0|^5.0
- symfony/filesystem: ^4.0|^5.0
- symfony/finder: ^4.0|^5.0
- symfony/framework-bundle: ^4.0|^5.0
- symfony/http-kernel: ^4.0|^5.0
- symfony/maker-bundle: ^1.13
- symfony/orm-pack: ^1.0
Requires (Dev)
- phpunit/phpunit: ^8.4
- symfony/security: ^4.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
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
-
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
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:
- To adapt the number of entities to generate, or the order
- 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.