r1pp3rj4ck / lipsum-bundle
r1pp3rj4ck LipsumBundle
Installs: 5 420
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
Type:symfony-bundle
Requires
- php: >5.3.2
- symfony/framework-bundle: >=2.1
This package is not auto-updated.
Last update: 2024-11-09 13:53:53 UTC
README
Generates bullshit for fixtures and other uses
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