kphoen / faker-service-provider
Faker Service Provider for Silex
Requires
- php: >=5.4.0
- fzaninotto/faker: ~1.0
Requires (Dev)
- phpunit/phpunit: >=3.7.0
- silex/silex: ~1.0@dev
This package is auto-updated.
Last update: 2022-02-01 12:26:57 UTC
README
A Faker service provider for Silex.
N.B: this provider is locale aware. It will automatically configure Faker to use the most suited locale for the request.
Status
This project is DEPRECATED and should NOT be used.
If someone magically appears and wants to maintain this project, I'll gladly give access to this repository.
Usage
Initialize it using register
. Its default behavior is to use Faker's factory
and try to guess the right locale to use.
<?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:
<?php use KPhoen\Provider\FakerServiceProvider; $app->register(new FakerServiceProvider('\Acme\Faker\Factory', $guessLocale = false), array( 'locale' => 'fr_FR', ));
From your controllers:
<?php $app->get('/hello', function() use ($app) { return 'Hello ' . $app['faker']->name; });
From Twig:
<!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:
$ php composer.phar require 'kphoen/faker-service-provider:~1.0'
Licence
This provider is released under the MIT license.