lichnow / alice-bundle
Symfony2 Bundle to manage fixtures with Alice and Faker.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.4.0
- nelmio/alice: ~2.1
- symfony/finder: ^2.7|~3.0
Requires (Dev)
- doctrine/doctrine-bundle: ~1.2
- doctrine/doctrine-fixtures-bundle: ~2.2
- doctrine/mongodb-odm: ^1.0
- doctrine/mongodb-odm-bundle: ^3.0
- doctrine/orm: ~2.4
- doctrine/phpcr-bundle: ^1.3
- doctrine/phpcr-odm: ^1.2
- jackalope/jackalope-doctrine-dbal: ^1.2
- sllh/php-cs-fixer-styleci-bridge: ~1.0
- symfony/console: ~2.3|~3.0
- symfony/framework-bundle: ~2.3|~3.0
- symfony/phpunit-bridge: ^2.7.4|~3.0
- symfony/validator: ~2.3|~3.0
- symfony/yaml: ~2.3|~3.0
Suggests
- doctrine/data-fixtures: To use Doctrine fixtures loader
- doctrine/doctrine-bundle: To use Doctrine with Symfony
- doctrine/mongodb-odm: To use Doctrine MongoDB
- doctrine/mongodb-odm-bundle: To use Doctrine MongoDB with Symfony
- doctrine/orm: To use Doctrine ORM
- doctrine/phpcr-bundle: To use Doctrine PHPCR ODM with Symfony
- doctrine/phpcr-odm: To use Doctrine PHPCR ODM
- jackalope/jackalope-doctrine-dbal: To use Doctrine PHPCR
- theofidry/alice-bundle-extension: Behat extension for HautelookAliceBundle
This package is auto-updated.
Last update: 2024-12-22 10:20:00 UTC
README
A Symfony bundle to manage fixtures with nelmio/alice and fzaninotto/Faker.
Currently supports Doctrine ORM, Doctrine ODM, Doctrine PHPCR ODM.
Documentation
- Install
- Basic usage
- Advanced usage
- Custom Faker Providers
- Custom Alice Processors
- DoctrineFixturesBundle support
- Resources
Other references:
Installation
First you need install appropriate database managers (if you didn't install it yet), according to your project requirements. Check the documentation here.
You can use Composer to install the bundle to your project:
composer require --dev hautelook/alice-bundle
Then, enable the bundle by updating your app/config/AppKernel.php
file to enable the bundle:
<?php // app/config/AppKernel.php public function registerBundles() { //... if (in_array($this->getEnvironment(), ['dev', 'test'])) { //... $bundles[] = new Hautelook\AliceBundle\HautelookAliceBundle(); } return $bundles; }
Configure the bundle to your needs (example with default values):
# app/config/config_dev.yml hautelook_alice: db_drivers: orm: ~ # Enable Doctrine ORM if is registered mongodb: ~ # Enable Doctrine ODM if is registered phpcr: ~ # Enable Doctrine PHPCR ODM if is registered locale: en_US # Locale to used for faker; must be a valid Faker locale otherwise will fallback to en_EN seed: 1 # A seed to make sure faker generates data consistently across runs, set to null to disable persist_once: false # Only persist objects once if multiple files are passed loading_limit: 5 # Maximum number of time the loader will try to load the files passed
Fore more information regarding the locale, refer to Faker documentation on localization.
Basic usage
Assuming you are using Doctrine, install
the doctrine/doctrine-bundle
and doctrine/data-fixtures
packages and register both bundles.
Then create a fixture file in AppBundle/DataFixtures/ORM
:
# AppBundle/DataFixtures/ORM/dummy.yml AppBundle\Entity\Dummy: dummy_{1..10}: name: <name()> related_dummy: @related_dummy*
# AppBundle/DataFixtures/ORM/related_dummy.yml AppBundle\Entity\RelatedDummy: related_dummy_{1..10}: name: <name()>
Then simply load your fixtures with the doctrine command php app/console hautelook_alice:doctrine:fixtures:load
(or php app/console h:d:f:l
).
If you want to load the fixtures of a bundle only, do php app/console h:d:f:l -b MyFirstBundle -b MySecondBundle
.
See more.
Next chapter: Advanced usage
Resources
- Behat extension: AliceBundleExtension
- Upgrade guide
- Changelog
Credits
This bundle was originaly developped by Baldur RENSCH and HauteLook. It is now maintained by Théo FIDRY.