定制 r1pp3rj4ck/lipsum-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

r1pp3rj4ck/lipsum-bundle

Composer 安装命令:

composer require r1pp3rj4ck/lipsum-bundle

包简介

r1pp3rj4ck LipsumBundle

README 文档

README

Generates bullshit for fixtures and other uses

Build Status Latest Stable Version Total Downloads Latest Unstable Version License Scrutinizer Quality Code Coverage

License

This bundle ships with MIT license. Full license available here

Installation

Step 1: Download r1pp3rj4ckLipsumBundle using Composer

Add r1pp3rj4ckLipsumBundle to your composer.json

{
    "require": {
        "r1pp3rj4ck/lipsum-bundle": "dev-master"
    }
}

Update your vendors:

$ php composer.phar update

Or you can also install only r1pp3rj4ckLipsumBundle:

$ php composer.phar update r1pp3rj4ck/lipsum-bundle

Step 2: Register the bundle in your kernel

You shouldn't have any reason to use this bundle in prod environment, so you can just register it in dev environment:

<?php
// app/AppKernel.php

if (in_array($this->getEnvironment(), array('dev', 'test'))) {
    // ...
    $bundles[] = new r1pp3rj4ck\LipsumBundle\r1pp3rj4ckLipsumBundle();
    // ...
}

(optional) Step 3: Change fixtures

This bundle ships with three fixture files containing 1219 male names, 1000 female names and 1000 last names. You can override these default files (e.g. frequent for names in your native language) in the configuration.

The files must contain one name per line.

# app/config_dev.yml

r1pp3rj4ck_lipsum:
    generator:
        profile:
            male_names: src/Acme/DemoBundle/DataFixtures/male_names.txt
            female_names: src/Acme/DemoBundle/DataFixtures/female_names.txt
            last_names: src/Acme/DemoBundle/DataFixtures/last_names.txt

(optional) Step 4: Override the default generator

You can override the default generator by implementing the r1pp3rj4ck\LipsumBundle\Generator\GeneratorInterface interface and add it to the configuration:

# app/config_dev.yml

r1pp3rj4ck_lipsum:
    generator:
        class: Acme\DemoBundle\Generator\Generator

Services

r1pp3rj4ck.lipsum.generator.profile - generates user data

Usage:

<?php

$profileGenerator = $this->container->get('r1pp3rj4ck.lipsum.generator.profile');

$userData    = $profileGenerator->getUserData(ProfileGenerator::SEX_RANDOM);
$refUserData = array(
  'fullName'   => 'John Doe',
  'firstName'  => 'John',
  'middleName' => '',
  'lastName'   => 'Doe',
  'userName'   => 'john.doe314',
  'email'      => 'john.doe314@gmail.com',
);
// $userData and $refUserData will look like the same but with another data
// ProfileGenerator::getUserData($sex = ProfileGenerator::SEX_RANDOM);
// possible $sex values: SEX_RANDOM, SEX_MALE, SEX_FEMALE

$name    = $profileGenerator->getName(ProfileGenerator::SEX_FEMALE, false)
$refName = array(
  'fullName'   => 'Jane Doe',
  'firstName'  => 'Jane',
  'middleName' => '',
  'lastName'   => 'Doe',
);
// $name and $refName will look like the same but with another data
// ProfileGenerator::getName($sex = ProfileGenerator::SEX_RANDOM, $middleName = false)

$firstName = $profileGenerator->getFirstName(ProfileGenerator::SEX_MALE);
$refFirstName = 'John';

$name        = 'Jane Mary Doe';
$userName    = $profileGenerator->getUserName($name);
$refUserName = 'jane.mary.doe813';
$email       = $profileGenerator->getEmail($userName);
$refEmail    = 'jane.mary.doe813@gmail.com';

r1pp3rj4ck.lipsum.generator.random - generates random strings

Usage:

<?php

$randomGenerator = $this->container->get('r1pp3rj4ck.lipsum.generator.random');

$lipsum = $randomGenerator->getRandom(42, RandomGenerator::PUNCTUATION_ON);
// $lipsum will be a 42 words long string, containing punctuation randomly,
// always with a dot on the end.
// possible punctuation values:
// PUNCTUATION_NONE   - no punctuation at all
// PUNCTUATION_AT_END - a dot at the end of string, nowhere else
// PUNCTUATION_ON     - (default) contains punctuation randomly + a dot at the end

r1pp3rj4ck.lipsum.generator.address - generates random addresses

Usage:

<?php

$addressGenerator = $this->container->get('r1pp3rj4ck.lipsum.generator.address');

$address = $addressGenerator->getStreetName();
// $address == 'Holly Drive'

$address = $addressGenerator->getAddress();
// $address == array(
//   'streetName'   => 'Holly Drive',
//   'streetNumber' => 242,
//   'fullAddress'  => 'Holly Drive 242',
// );

Configuration Reference

This configuration reference contains the default values of everything:

# app/config_dev.yml

r1pp3rj4ck_lipsum:
    generator:
        profile:
            male_names: vendor/r1pp3rj4ck/lipsum-bundle/data/malenames.txt
            female_names: vendor/r1pp3rj4ck/lipsum-bundle/data/femalenames.txt
            last_names: vendor/r1pp3rj4ck/lipsum-bundle/data/lastnames.txt
            class: r1pp3rj4ck\LipsumBundle\Generator\ProfileGenerator
        random:
            random: vendor/r1pp3rj4ck/lipsum-bundle/data/lipsum.txt
            class: r1pp3rj4ck\LipsumBundle\Generator\RandomGenerator
        address:
            street_names: vendor/r1pp3rj4ck/lipsum-bundle/data/streetnames.txt
            class: r1pp3rj4ck\LipsumBundle\Generator\AddressGenerator

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-09-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固