2017 © Pedro Peláez
 

symfony-bundle symfony-fakerino

Fake data generator symfony bundle

image

fakerino/symfony-fakerino

Fake data generator symfony bundle

  • Sunday, June 21, 2015
  • by niklongstone
  • Repository
  • 1 Watchers
  • 5 Stars
  • 33 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

FakerinoBundle

Latest Stable Version Travis Ci License, (*1)

The FakerinoBundle provides integration of Fakerino into the Symfony2 framework.
This bundle also include a Fakerino Twig extension., (*2)

More information in the official documentation., (*3)

Installation

1. Install symfony-fakerino

Add the following dependency to your projects composer.json file:, (*4)

    "require": {
        "fakerino/symfony-fakerino": "~0.1"
    }

2. Install the ODS data sample (optional but suggested)

Install the ODS data sample using one of the below options:, (*5)

2.1 Install and update automatically adding a script to your composer.json (suggested way):
  "scripts": {
        "post-install-cmd": "vendor/fakerino/fakerino/build/ods vendor/fakerino/fakerino/data",
        "post-update-cmd": "vendor/fakerino/fakerino/build/ods vendor/fakerino/fakerino/data"
    }

NOTE: add as first script to be executed., (*6)

2.2 Run the command manually (after the fakerino composer installation):

```sh $ vendor/fakerino/fakerino/build/ods vendor/fakerino/fakerino/data, (*7)


### 3. Initializing the bundle To initialize the bundle, you'll need to add it in your `app/AppKernel.php`. ```PHP public function registerBundles() { // ... $bundles = array( new Fakerino\Bundle\FakerinoBundle\FakerinoBundle(), // ... }

4. Configuration (optional)

If the configuration is not set, Fakerino will use the default values.
Configuration example config.yml:, (*8)

fakerino:
    config:
        locale: en-GB
        fake:
            fakeMale:
              - titlemale
              - nameMale
              - surname
            fakeFemale:
              - titlefemale
              - namefemale
              - surname
        database:
            dbname: mydb
            user: username
            password: password
            host: localhost
            driver: pdo_mysql

Example

Controller

<?php
namespace Acme\DemoBundle\Controller;

use Fakerino\Core\FakeDataFactory;
use Symfony\Component\HttpFoundation\Response;
use Twig_Environment;

class HelloController
{
    public function __construct(FakeDataFactory $fakerino, Twig_Environment $twig)
    {
        $this->fakerino = $fakerino;
        $this->twig = $twig;
    }

    public function helloAction()
    {
        $person = $this->fakerino->fake('fakeFemale');
        $duty = $this->fakerino->fakeTemplate('<p>Remeber the appointment with {{ surname }} in {{ country }}</p>');

        return new Response('<html><body> Hello '.$person.'!'.$duty.'</body></html>');
    }

    public function twigAction()
    {
        return new Response(
            $this->twig->render('AcmeDemoBundle:Demo:my_fakerino_demo.html.twig')
        );
    }
}  

Twig file

{# Resources/view/Demo/my_fakerino_demo.html.twig #}

Hello Mr {{fake('surname')}}

Service configuration

//config/services.xml
<service id="hello_service" class="Acme\DemoBundle\Controller\HelloController">
    <argument type="service" id="fakerino" />
    <argument type="service" id="twig" />
</service>

For more information about the service configuration and the controller used in this example, please read about:
Service Container and Controller as a Service on the official Symfony documentation., (*9)

Outputs

Output of helloAction(), will changes at every page refresh:, (*10)

Hello Ms Adeline Douglas !

Remeber the appointment with Watts in Cyprus

Output of twigAction(), will changes at every page refresh:, (*11)

Hello Mr Wallace

The Versions

21/06 2015

dev-master

9999999-dev http://github.com/niklongstone/symfony-fakerino

Fake data generator symfony bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle generator symfony faker data fake

16/06 2015
28/05 2015
26/05 2015

0.0.2

0.0.2.0 http://github.com/niklongstone/symfony-fakerino

Fake data generator symfony bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle generator symfony faker data fake

22/05 2015

0.0.1

0.0.1.0 http://github.com/niklongstone/symfony-fakerino

Fake data generator symfony bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

bundle generator symfony faker data fake