lkovace18 / entity-factory-bundle
Symfony 4 的实体工厂包
v1.1.0
2018-10-02 12:53 UTC
Requires
- php: >= 7.1
- dflydev/dot-access-data: ^1.0
- doctrine/doctrine-bundle: ^1.6
- doctrine/orm: ^2.5
- fzaninotto/faker: ^1.5
- symfony/console: >=3.2.13 || ^4.0
- symfony/dependency-injection: >=3.2.13 || ^4.0
- symfony/expression-language: >=3.2.13 || ^4.0
- symfony/property-access: >=3.2.13 || ^4.0
- symfony/yaml: >=3.2.13 || ^4.0
Requires (Dev)
- matthiasnoback/symfony-dependency-injection-test: ^0.7.6
- mikey179/vfsstream: ^1.6.1
- phpunit/phpunit: ^5.6
- symfony/finder: ^3.2 || ^4.0
- symfony/framework-bundle: >=3.2.13 || ^4.0
- symfony/http-kernel: >=3.2.13 || ^4.0
This package is auto-updated.
Last update: 2024-09-29 03:36:28 UTC
README
使用方法
如何使用
创建实体
$factory->create(User::class);
创建多个实体
$factory->times(10)->create(Beer::class); /* This will generate 10 persisted beers with fake values */
创建实体并覆盖一些数据
$user = $factory->create( User::class, [ 'username' => 'BadassAdmin' 'active' => true ] );
创建新实例
$post = $factory->make(User::class)
获取实体的伪造值
可能你不需要实体的实例,而是需要一些伪造数据来创建你的实体对象。values
方法将返回一个实体的伪造值数组。
$productData = $factory->values(User::class);