mrgoodbytes8667 / faker-providers
A Faker Factory, Generator, and some providers
Installs: 1 230
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- fakerphp/faker: ^1.13
- illuminate/collections: ^9 | ^10 | ^11 | ^12
- mmo/faker-images: ^0.8 | ^0.9
- symfony/deprecation-contracts: ^2.1 | ^3
- symfony/string: ^5.2 | ^6.0 | ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.58
- rector/rector: ^1.0
- symfony/test-pack: ^1.0.9
Suggests
- mrgoodbytes8667/test-common-faker: For easily adding Faker to tests
- zenstruck/foundry: For creating entity factories for test/fixture purposes
Conflicts
- phpunit/phpunit: <9.5 || 9.5.8
README
A Faker Factory, Generator, and some providers
Installation
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and execute:
$ composer require mrgoodbytes8667/faker-providers
Usage
use Bytes\Common\Faker\Factory; $faker = Factory::create(); $faker->camelWords(); $faker->snakeWords(); $faker->oneOrMoreOf(['some', 'iterable', 'object']); $faker->rangeBetween(4, 1, 2); $faker->randomAlphanumericString(); $faker->paragraphsMinimumChars();
The included replacement Factory removes the now deprecated Faker image provider and replaces it with the mmo/faker-images provider, and adds other included providers by default. It returns an overloaded Generator for code completion purposes as well.
With PHPUnit
See test-common-faker for easy PHPUnit test integration
With Zenstruck/Foundry
Add the following to Kernel.php
to replace the default Faker Generator with this one, adding in these providers
public function process(ContainerBuilder $container): void { $container->getDefinition('.zenstruck_foundry.faker')->setFactory([\Bytes\Common\Faker\Factory::class, 'create']); }
License
Faker Providers by MrGoodBytes is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
Based on a work at https://github.com/mrgoodbytes8667/faker-providers.