Using custom error data providers without standard doctrine tools in Nelmio Alice

I am setting up NelmioAlice and Faker in a Symfony2 project via AlixeFixturesBundle . I need a compiled device, for example, for example:

    veeva_rep_id (unique): qlv_005800000067SwzAAE


which is a prefix qlv_

followed by a random string of 18 characters. The best way I've found to do this (if anyone knows of another or better way to do this, let me know) was using a custom faker and I wrote this piece of code:

 * FakerProvider: VeevaProvider.

namespace PDI\PDOneBundle\DataFixtures;

use ReverseRegex\Lexer;
use ReverseRegex\Random\SimpleRandom;
use ReverseRegex\Parser;
use ReverseRegex\Generator\Scope;

class VeevaProvider extends \Faker\Provider\Base
    public function veevaRepId()
        $lexer = new  Lexer('[a-zA-Z0-9]{18}');
        $gen = new SimpleRandom(10007);
        $result = '';

        $parser = new Parser($lexer, new Scope(), new Scope());
        $parser->parse()->getResult()->generate($result, $gen);

        return 'qlv_' . $result;


As explained here in the Faker docs. Now here at NelmioAlice the author explains how to add Custom Faker Data Providers but uses Doctrine Fixtures which I have wrong, having this, how to download and use the provider I wrote on fixtures? Are there any tips on this?


source to share

1 answer

It should be as simple as passing an instance of the provider in Loader

when you create it:

$loader = new Loader('en_US', [new VeeveProvider]);



All Articles