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:
<?php
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:
# app/config/services.yml
services:
data_fixtures.provider.foo:
class: App\DataFixtures\Provider\FooProvider
tags: [ { name: nelmio_alice.faker.provider } ]
That's it! You can now use it in your fixtures:
# app/Resources/fixtures/orm/dummy.yml
AppBundle\Entity\Dummy:
brand{1..10}:
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