fakerino / nette-fakerino
Nette extension for Fakerino
0.0.2
2015-06-18 22:33 UTC
Requires
- php: >=5.3.0
- fakerino/fakerino: ~0.8
This package is not auto-updated.
Last update: 2024-11-09 19:19:54 UTC
README
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'); } }