fakerphp/faker 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fakerphp/faker

Composer 安装命令:

composer require fakerphp/faker

包简介

Faker is a PHP library that generates fake data for you.

README 文档

README

Social card of FakerPHP

Faker

Packagist Downloads GitHub Workflow Status Type Coverage Code Coverage

Faker is a PHP library that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you.

It's heavily inspired by Perl's Data::Faker, and by Ruby's Faker.

Getting Started

Installation

Faker requires PHP >= 7.4.

composer require fakerphp/faker

Documentation

Full documentation can be found over on fakerphp.github.io.

Basic Usage

Use Faker\Factory::create() to create and initialize a Faker generator, which can generate data by accessing methods named after the type of data you want.

<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

// use the factory to create a Faker\Generator instance
$faker = Faker\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.'

Each call to $faker->name() yields a different (random) result. This is because Faker uses __call() magic, and forwards Faker\Generator->$method() calls to Faker\Generator->format($method, $attributes).

<?php

declare(strict_types=1);

for ($i = 0; $i < 3; $i++) {
    echo $faker->name() . "\n";
}

// 'Cyrus Boyle'
// 'Alena Cummerata'
// 'Orlo Bergstrom'

Automated refactoring

If you already used this library with its properties, they are now deprecated and needs to be replaced by their equivalent methods.

You can use the provided Rector config file to automate the work.

Run

composer require --dev rector/rector

to install rector/rector.

Run

vendor/bin/rector process src/ --config vendor/fakerphp/faker/rector-migrate.php

to run rector/rector.

Note: do not forget to replace src/ with the path to your source directory.

Alternatively, import the configuration in your rector.php file:

<?php

declare(strict_types=1);

use Rector\Config;

return static function (Config\RectorConfig $rectorConfig): void {
    $rectorConfig->import('vendor/fakerphp/faker/rector-migrate.php');
};

License

Faker is released under the MIT License. See LICENSE for details.

PHP Version Support Policy

The maintainers of this package add support for a PHP version following its initial release and drop support for a PHP version one year after it has reached its end of security support.

Backward compatibility promise

Faker is using Semver. This means that versions are tagged with MAJOR.MINOR.PATCH. Only a new major version will be allowed to break backward compatibility (BC).

Classes marked as @experimental or @internal are not included in our backward compatibility promise. You are also not guaranteed that the value returned from a method is always the same. You are guaranteed that the data type will not change.

PHP 8 introduced named arguments, which increased the cost and reduces flexibility for package maintainers. The names of the arguments for methods in Faker is not included in our BC promise.

fakerphp/faker 适用场景与选型建议

fakerphp/faker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 390M 次下载、GitHub Stars 达 3.97k, 最近一次更新时间为 2020 年 10 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「faker」 「fixtures」 「data」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 fakerphp/faker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 fakerphp/faker 我们能提供哪些服务?
定制开发 / 二次开发

基于 fakerphp/faker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 390M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4055
  • 点击次数: 25
  • 依赖项目数: 4141
  • 推荐数: 67

GitHub 信息

  • Stars: 3973
  • Watchers: 26
  • Forks: 3586
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-27