nelmio/alice random string with specified long

2.4k views Asked by At

I was trying to find way generate random unique string with 8 characters long using nelmio/alice.

And I've found only <uuid()> (token (unique): <uuid()>)method, unfortunately it returns too long string, I need just 8 characters.

May be some one knows elegant solution?

2

There are 2 answers

0
Mykyta Popov On BEST ANSWER

Thanks I've found solution

token (unique): '<( substr( md5( uniqid( rand(), true ) ) , 0, 8) )>'
0
itnelo On

nelmio/alice uses fzaninotto/Faker for data generation, you can use Faker\Provider\Lorem or Faker\Provider\en_US\Text:

<sentence($nbWords = 6, $variableNbWords = true)>
<text($maxNbChars = 200)>
<realText($maxNbChars = 200, $indexSize = 2)>