Componette

Componette

Fakerino

Fakerino / nette-fakerino 0.0.2

Nette Fakerino extension

download-cloud-line composer require fakerino/nette-fakerino

Fakerino Nette

Latest Stable Version License

Provides an easy way to include Fakerino in Nette framework as a service.

More information in the official documentation.

Installation

Add the following dependencies to your projects composer.json file:

    "require": {
        "fakerino/nette-fakerino": "0.0.*",
    }

Install the Open Data Sample in two ways:

  • Add a script to your composer.json:
  "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"
    }

In this way the data will be always updated automatically via composer.

  • Run maually the command (after the fakerino composer installation): $ vendor/fakerino/fakerino/build/ods vendor/fakerino/fakerino/data

Configuration

Add in your config.neon the service definition as below:

services:
	fakerino:
	    class: Fakerino\Core\FakeDataFactory
	    factory: Fakerino\FakerinoNette\FakerinoServiceFactory::create

In order to customise the Fakerino default configuration you could add fakerino in your config.neon parameters.

parameters:
    fakerino:
        locale: cs-CZ
        fake:
            fakeMale:
              - titlemale
              - nameMale
              - surname
            fakeFemale:
              - titlefemale
              - namefemale
              - surname
        database:
            dbname: mydb
            user: username
            password: password
            host: localhost
            driver: pdo_mysql

Presenter example

<?php

namespace App\Presenters;

use Nette,
	App\Model;
use Fakerino\Core\FakeDataFactory;

/**
 * Homepage presenter.
 */
class HomepagePresenter extends Nette\Application\UI\Presenter
{
    /**
     * @var \Fakerino\Core\FakeDataFactory
     */
    private $fakerino;

    public function __construct(FakeDataFactory $fakerino)
    {
        $this->fakerino = $fakerino;
    }

	public function renderDefault()
	{
		$this->template->surname = $this->fakerino->fake('surname');
	}
}
  • 0.0.2 0.0.2

    • Add support for new Fakerino releases
  • 0.0.1 0.0.1

    • First release
Componette Componette felix@nette.org