nicholasjohn16/generate 问题修复 & 功能扩展

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

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

nicholasjohn16/generate

Composer 安装命令:

composer require nicholasjohn16/generate

包简介

Generate Command for Anahita CLI

README 文档

README

The Generate Command is used to automatically generate sample data for testing and development.

Installation

Installation is done through composer. Since this is a dev tool, requiring it as a dev tool so it's not installed in production.

composer require nicholasjohn16/generate --dev

Usage

The Genereate Command is integrated into Anahita's CLI. To use it, you just need to pass in the repo and entity name that you wish to generate sample data for. Optionally, you can pass in the number of entities to generate using the count argument. This is 10 by default.

anahita generate:sample repo.entity [--count|-c="..."] [relationships1] ... [relationshipsN]

For example:

anahita generate:sample people.person

The above command will generate 10 person entities.

Relationships

Relationships can be specified when generating entities. For one to many relationships, you can optionally provide an id for the relationship by seperating the relationship name and id with a colon. If no id is provided, the child for the relationship will be randomly selected.

For example if we wanted to randomly generate a note with an owner of id 2 with a random author, we'd use the below command:

anahita generate:sample notes.note owner:2 author

Many to many relationships are not yet supported.

Attributes

Attributes are generated randomly based on their entity definition. Non-required attributes have a chance of being null. If the generated value is null and they have a default value, the default value will be used instead. Faker PHP Library is used to generate the random values. The provider used for each attribute is based on the config.json settings. Each attribute type has it's own set of defaults, followed by defaults for each entity attributes. Attributes not listed in will be skipped over and not generated.

These defaults can be overriden and extended to include attributes for your own entities. For your own projects, create a sample.json file in the main directory of your Anahita installation and add an repo and entity object like below.

{
  "myrepo": {
    "myentity": {

    }
  }
}

Then within your entity, list any additional attributes that you'd like to be randomly generated. As well, you can optional override the provider used for the attribute type and any arguments that are passed to it. You can also override core defaults using the same method. Providers must return a string, int, boolean or DateTime object.

{
  "myrepo": {
    "myentity": {
      "bookISBN": {
        "provider": "isbn13"
      },
      "enabled": {
        "arguments": [50]
      },
      "subtitle": {}
    }
  }
}

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2018-06-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固