百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

faker-cli

> 编程语言
开源

[PHP/CLI] 用于 Faker PHP 库的命令行工具。

175 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

[PHP/CLI] 用于 Faker PHP 库的命令行工具。

Faker Command Line Tool

Faker is a PHP library that generates fake data for you. This is a command line tool for easy generation of fake data in a static way.

Usage

As a Phar (Recommended)

You can find the latest phar on the releases page.

bash
$ wget https://github.com/bit3/faker-cli/releases/download/1.4/faker.phar
$ ./faker.phar

As a Composer Install

bash
$ composer create-project bit3/faker-cli
$ cd faker-cli
$ ./bin/faker.php

Parameters and arguments

…

Single value generator example

$ ./bin/faker.php word

culpa
consequatur
quisquam
recusandae
asperiores
accusamus
nihil
repellat
vero
omnis

Multi value generator example

$ ./bin/faker.php --count 5 words 2

culpa,consequatur
quisquam,recusandae
asperiores,accusamus
nihil,repellat
vero,omnis

Output formats

You can use different output formats by definint the --format option. JSON is the default format.

JSON output

$ ./bin/faker.php word

[
    "culpa",
    "consequatur",
    "quisquam",
    "recusandae",
    "asperiores",
    "accusamus",
    "nihil",
    "repellat",
    "vero",
    "omnis"
]
$ ./bin/faker.php --count 5 words 2

[
    [
        "culpa",
        "consequatur"
    ],
    [
        "quisquam",
        "recusandae"
    ],
    [
        "asperiores",
        "accusamus"
    ],
    [
        "nihil",
        "repellat"
    ],
    [
        "vero",
        "omnis"
    ]
]

XML output

$ ./bin/faker.php --format xml word

  culpa
  consequatur
  quisquam
  recusandae
  asperiores
  accusamus
  nihil
  repellat
  vero
  omnis

CSV output

$ ./bin/faker.php --format csv word

culpa
consequatur
quisquam
recusandae
asperiores
accusamus
nihil
repellat
vero
omnis

PHP output

$ ./bin/faker.php --format php word

array (
  0 => 'culpa',
  1 => 'consequatur',
  2 => 'quisquam',
  3 => 'recusandae',
  4 => 'asperiores',
  5 => 'accusamus',
  6 => 'nihil',
  7 => 'repellat',
  8 => 'vero',
  9 => 'omnis',
)

printf and vprintf output

The printf and vprintf output are mostly equal. But printf is designed for single value generator types e.g. safeEmail and vprintf is designed for multi value generator types e.g. words 5.

…
…

You can also use printf with multi value generator types, which will joined by the --delimiter char, which is , by default.

…

It is recommend to use the --enclosure option. each occurrence of the --enclosure char will be escaped with the --escape char, which is \\ by default.

Build your own Phar

Install and run php-box:

bash
$ curl -LSs https://box-project.github.io/box2/installer.php | php
$ ./box.phar build

License

Faker Command Line Tool is released under the MIT Licence. See the bundled LICENSE file for details.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHP

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言