mrgoodbytes8667/faker-providers

A Faker Factory, Generator, and some providers

v0.6.1 2024-08-16 14:53 UTC

This package is auto-updated.

Last update: 2024-09-16 15:00:32 UTC


README

Packagist Version PHP from Packagist Symfony Versions Supported Symfony LTS Version Symfony Stable Version Symfony Dev Version Packagist License GitHub Release Workflow Status GitHub Tests Workflow Status GitHub Coverage Workflow Status codecov
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

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.