FakerServiceProvider
A Faker service provider for Silex., (*1)
N.B: this provider is locale aware. It will automatically configure Faker
to use the most suited locale for the request., (*2)
Status
This project is DEPRECATED and should NOT be used., (*3)
If someone magically appears and wants to maintain this project, I'll gladly give access to this repository., (*4)
Usage
Initialize it using register. Its default behavior is to use Faker's factory
and try to guess the right locale to use., (*5)
<?php
use KPhoen\Provider\FakerServiceProvider;
$app->register(new FakerServiceProvider());
In this example, we use a custom factory and force the locale (both in the
provider and in the whole application) to fr_FR:, (*6)
<?php
use KPhoen\Provider\FakerServiceProvider;
$app->register(new FakerServiceProvider('\Acme\Faker\Factory', $guessLocale = false), array(
'locale' => 'fr_FR',
));
From your controllers:, (*7)
<?php
$app->get('/hello', function() use ($app) {
return 'Hello ' . $app['faker']->name;
});
From Twig:, (*8)
<!DOCTYPE html>
<html>
<body>
<p>Hello {{ app.faker.name }}!</p>
</body>
</html>
Installation
Install the FakerServiceProvider adding kphoen/faker-service-provider to your composer.json or from CLI:, (*9)
$ php composer.phar require 'kphoen/faker-service-provider:~1.0'
Licence
This provider is released under the MIT license., (*10)