nelmio /爱丽丝随机字符串指定long

问题描述 投票:1回答:2

我试图找到办法生成随机唯一的字符串长使用nelmio /爱丽丝8个字符。

而且我发现只有<uuid()>token (unique): <uuid()>)方法,遗憾的是它返回过长的字符串,我只需要8个字符。

可能有些人知道优雅的解决方案?

symfony random fixtures nelmio-alice alice-fixtures
2个回答
1
投票

谢谢,我已经找到解决方案

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

0
投票

nelmio/alice使用fzaninotto/Faker数据生成,您可以使用Faker\Provider\LoremFaker\Provider\en_US\Text

<sentence($nbWords = 6, $variableNbWords = true)>
<text($maxNbChars = 200)>
<realText($maxNbChars = 200, $indexSize = 2)>
© www.soinside.com 2019 - 2024. All rights reserved.