johnykvsky / fejker
Faker 的精简版本。Faker 是一个 PHP 库,用于为您生成假数据。
v0.1.0
2023-06-19 15:46 UTC
Requires
- php: ^8.1
- phpwatch/simple-container: ^2.0
- psr/container: ^1.0 || ^2.0
- symfony/deprecation-contracts: ^2.2 || ^3.0
Requires (Dev)
- ext-intl: *
- bamarni/composer-bin-plugin: ^1.8.2
- doctrine/persistence: ^2.0 || ^3.0
- phpstan/extension-installer: ~1.3.1
- phpstan/phpstan: ~1.10.19
- phpunit/phpunit: ~10.2.2
- squizlabs/php_codesniffer: 3.*
- symfony/phpunit-bridge: ^5.4.16
- thecodingmachine/phpstan-strict-rules: ~1.0.0
Suggests
- ext-curl: Required by Fejker\Provider\Image to download images.
- ext-mbstring: Required for multibyte Unicode string functionality.
- doctrine/orm: Required to use Fejker\ORM\Doctrine
This package is auto-updated.
Last update: 2024-09-19 18:44:30 UTC
README
这是 fakerphp.github.io 的精简 (~9Mb 更少) 版本。
仅支持以下语言: en_GB
, en_US
, pl_PL
变更
- 用
phpwatch/simple-container
替换了自定义 DI 容器 - 添加了类型提示 (删除了 phpdoc 参数)
- 添加了
declare(strict_types=1);
- 删除了除
en_GB
,en_US
,pl_PL
之外的所有语言 - 删除了 ORM 支持
- 删除了已弃用的代码(因为这与原始 Faker 已经是 BC 破坏性的更改)
- 删除了 File、Image、HtmlLorem 提供者
- 删除了 Barcode 提供者(仍然有 Barcode 扩展)
基本用法
使用 Fejker\Factory::create()
创建并初始化一个 Fejker 生成器,可以通过访问以数据类型命名的方法来生成数据。
<?php // use the factory to create a Fejker\Generator instance $faker = Fejker\Factory::create(); // generate data by calling methods echo $faker->name(); // 'Vince Sporer' echo $faker->email(); // 'walter.sophia@hotmail.com' echo $faker->text(); // 'Numquam ut mollitia at consequuntur inventore dolorem.'
许可
MIT 许可证 (MIT)。请参阅 许可文件 获取更多信息。