Skip to content
Branch: master
Find file Copy path
Find file Copy path
2 contributors

Users who have contributed to this file

@theofidry @bwoodmansee
61 lines (42 sloc) 1.56 KB

Faker Providers

As explained in nelmio/alice documentation, you have three ways to declare custom data provider. To use Custom Faker Provider classes you will have to declare them as services:


namespace AppBundle\DataFixtures\Faker\Provider;

class FooProvider
    public static function foo($str)
        return 'foo'.$str;

Then declare it as a service with the nelmio_alice.faker.provider tag unless you have autoconfigure enabled:

# config/services.yaml

    AppBundle\DataFixtures\Faker\Provider\FooProvider: ~

Without autoconfigure:

# config/services.yaml

        tags: [ { name: nelmio_alice.faker.provider } ]

That's it! You can now use it in your fixtures:

# fixtures/orm/dummy.yml (Sf4)
# or app/Resources/fixtures/orm/dummy.yml

        name: <foo('a string')>

Warning: rely on Custom Faker Providers helpers to generate random data (most of them are static).

Refer to nelmio/alice for a more advanced documentation.

Previous chapter: Advanced usage
Next chapter: Custom Alice Processors

You can’t perform that action at this time.