Skip to content

Commit

Permalink
Update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Sep 12, 2016
1 parent f4b1681 commit 4f4cd7c
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 422 deletions.
30 changes: 0 additions & 30 deletions CHANGELOG.md

This file was deleted.

109 changes: 38 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
AliceBundle
AliceDataFixtures
===========

A [Symfony](http://symfony.com) bundle to manage fixtures with [nelmio/alice](https://github.com/nelmio/alice) and
[fzaninotto/Faker](https://github.com/fzaninotto/Faker).

Currently supports [Doctrine ORM](http://www.doctrine-project.org/projects/orm.html), [Doctrine ODM](http://doctrine-mongodb-odm.readthedocs.org/en/latest/), [Doctrine PHPCR ODM](http://doctrine-phpcr-odm.readthedocs.org/en/latest/).

[![Package version](https://img.shields.io/packagist/v/hautelook/alice-bundle.svg?style=flat-square)](https://packagist.org/packages/hautelook/alice-bundle)
[![Build Status](https://img.shields.io/travis/hautelook/AliceBundle/master.svg?style=flat-square)](https://travis-ci.org/hautelook/AliceBundle?branch=1.x)
[![SensioLabsInsight](https://img.shields.io/sensiolabs/i/d93a3fc4-3fe8-4be3-aa62-307f53898199.svg?style=flat-square)](https://insight.sensiolabs.com/projects/d93a3fc4-3fe8-4be3-aa62-307f53898199)
[![Dependency Status](https://www.versioneye.com/user/projects/55d26478265ff6001a000084/badge.svg?style=flat)](https://www.versioneye.com/user/projects/55d26478265ff6001a000084)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/hautelook/AliceBundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/hautelook/AliceBundle/?branch=master)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/hautelook/AliceBundle.svg?b=master&style=flat-square)](https://scrutinizer-ci.com/g/hautelook/AliceBundle/?branch=master)
[![HHVM support](https://img.shields.io/hhvm/hautelook/alice-bundle/master.svg?style=flat-square)](http://hhvm.h4cc.de/package/hautelook/alice-bundle)
[Alice](https://github.com/nelmio/alice) 3.x no longer ships with a persistence layer, so this library provides one!

[![Package version](https://img.shields.io/packagist/vpre/theofidry/alice-data-fixtures.svg?style=flat-square)](https://packagist.org/packages/theofidry/alice-data-fixtures)
[![Build Status](https://img.shields.io/travis/theofidry/AliceDataFixtures/master.svg?style=flat-square)](https://travis-ci.org/theofidry/AliceDataFixtures?branch=master)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hautelook/AliceBundle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

## Documentation

1. [Install](#installation)
2. [Basic usage](#basic-usage)
3. [Advanced usage](doc/advanced-usage.md)
1. [Enabling databases](doc/advanced-usage.md#enabling-databases)
2. [Fixtures parameters](doc/advanced-usage.md#fixtures-parameters)
3. [Doctrine ORM](doc/advanced-usage.md#doctrine-orm)
4. [Doctrine ODM (MongoDB)](doc/advanced-usage.md#doctrine-odm-and-doctrine-phpcr-odm)
5. [Doctrine PHPCR ODM](doc/advanced-usage.md#doctrine-odm-and-doctrine-phpcr-odm)
4. [Custom Faker Providers](doc/faker-providers.md)
1. [Simple Provider](doc/faker-providers.md#simple-provider)
2. [Advanced Provider](doc/faker-providers.md#advanced-provider)
5. [Custom Alice Processors](doc/alice-processors.md)
6. [DoctrineFixturesBundle support](doc/doctrine-fixtures-bundle.md)
7. [Resources](#resources)

Other references:

* [Knp University screencast](https://knpuniversity.com/screencast/alice-fixtures)
1. [Symfony Bundle](#symfony)
1. [Basic usage](#basic-usage)


## Installation

Expand All @@ -48,7 +25,23 @@ You can use [Composer](https://getcomposer.org/) to install the bundle to your p
composer require --dev hautelook/alice-bundle doctrine/data-fixtures
```

Of course, the `doctrine/data-fixtures` library is only needed if you're using Doctrine.
Then you can install the library:

```bash
composer require --dev theofidry/alice-persistence

# If you are using Doctrine ORM:

composer require --dev theofidry/alice-persistence doctrine/orm doctrine/data-fixtures

```

If you are working with Doctrine ORM, you need to install the following packages as well:

### Symfony

This library ships with a Symfony bundle. To use it with Doctrine do not forget to install `doctrine/doctrine-bundle`
and enable the `DoctrineBundle` (done by default in Symfony Standard Edition).

Then, enable the bundle by updating your `app/AppKernel.php` file to enable the bundle:

Expand All @@ -61,41 +54,23 @@ public function registerBundles()
//...
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
//...
$bundles[] = new Hautelook\AliceBundle\HautelookAliceBundle();
$bundles[] = new Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle();
}

return $bundles;
}
```

Configure the bundle to your needs (example with default values):

```yaml
# 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](https://github.com/fzaninotto/Faker#localization).

## Basic usage

Assuming you are using [Doctrine](http://www.doctrine-project.org/projects/orm.html), make sure you
have the [`doctrine/doctrine-bundle`](https://github.com/doctrine/DoctrineBundle) and [`doctrine/data-fixtures`](https://github.com/doctrine/data-fixtures) packages installed.

Then create a fixture file in `src/AppBundle/DataFixtures/ORM`:
Then create a fixture file in `src/AppBundle/Resources/fixtures`:

```yaml
# src/AppBundle/DataFixtures/ORM/dummy.yml
# src/AppBundle/Resources/fixtures/dummy.yml

AppBundle\Entity\Dummy:
dummy_{1..10}:
Expand All @@ -104,34 +79,26 @@ AppBundle\Entity\Dummy:
```
```yaml
# AppBundle/DataFixtures/ORM/related_dummy.yml
# src/AppBundle/Resources/fixtures/related_dummy.yml

AppBundle\Entity\RelatedDummy:
related_dummy_{1..10}:
name: <name()>
```
Then simply load your fixtures with the doctrine command `php app/console fixtures:load`.

If you want to load the fixtures of a bundle only, do `php app/console fixtures:load -b MyFirstBundle -b MySecondBundle`.

[See more](#documentation).<br />
Next chapter: [Advanced usage](doc/advanced-usage.md)
Then you can load those files using a `LoaderInterface`:

```php
$files = [
'path/to/src/AppBundle/Resources/fixtures/dummy.yml',
'path/to/src/AppBundle/Resources/fixtures/related_dummy.yml',
];
## Resources

* Behat extension: [AliceBundleExtension](https://github.com/theofidry/AliceBundleExtension)
* Bundle for generating AliceBundle compatible fixtures directly from Doctrine entities: [AliceGeneratorBundle](https://github.com/trappar/AliceGeneratorBundle)
* [Upgrade guide](UPGRADE.md)
* [Upgrade from 0.X to 1.X](UPGRADE.md#from-0x-to-1x)
* [Changelog](CHANGELOG.md)

## Credits

This bundle was originaly developped by [Baldur RENSCH](https://github.com/baldurrensch) and [HauteLook](https://github.com/hautelook). It is now maintained by [Théo FIDRY](https://github.com/theofidry).
$loader = $container->get('fidry_alice_data_fixtures.loader');
$objects = $loader->load($files);
[Other contributors](https://github.com/hautelook/AliceBundle/graphs/contributors).
// $objects is now an array of persisted `Dummy` and `RelatedDummy`
```

## License

Expand Down
28 changes: 0 additions & 28 deletions UPGRADE.md

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "theofidry/alice-persistence",
"name": "theofidry/alice-data-fixtures",
"description": "Nelmio alice extension to persist the loaded fixtures",
"keywords": ["Fixture", "ORM", "Alice", "Faker", "data", "tests"],
"type": "library",
Expand Down
131 changes: 0 additions & 131 deletions doc/advanced-usage.md

This file was deleted.

17 changes: 0 additions & 17 deletions doc/alice-processors.md

This file was deleted.

Loading

0 comments on commit 4f4cd7c

Please sign in to comment.