This is a custom provider for fakerphp/Faker generating fake news headlines for use when testing website design. Also includes a fake news source name generator.
You can install the package via composer:
composer require paulhennell/faker-news
$faker = (new \Faker\Factory())::create();
$faker->addProvider(new \Faker\Provider\Fakenews($faker));
$faker->addProvider(new \Faker\Provider\Fakenewssource($faker));
// generate a headline
echo $faker->headline;
// generate a named newssource (75% Newspapers, 25% TV news as below)
echo $faker->NewssourceName;
// generate a Newspaper name
// 'The Daily Texas', 'The Morning Herald', 'Manchester Post' etc
echo $faker->NewspaperName;
// generate a TV source name
// 'KKN News', 'ATV', 'JKK 247' etc
echo $faker->TvNewsName;
Create a FakerService provider (and register in bootstrap/providers.php
class FakerServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(\Faker\Generator::class, function () {
$faker = \Faker\Factory::create();
$faker->addProvider(new Fakenews($faker));
$faker->addProvider(new Fakenewssource($faker));
return $faker;
});
}
You can now access the fields in the model factories:
'headline' => $this->faker->headline(),
'publisher' => $this->faker->NewssourceName(),
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.
This package was generated using the PHP Package Boilerplate.