Provides an easy way to include Fakerino in Nette framework as a service.
More information in the official documentation.
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
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
<?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');
}
}