A custom image provider for the FakerPHP library.
The package uses LOREM PICSUM to generate url's and images.
composer require psn/faker-image-provider
-
add provider
$faker = Faker\Factory::create(); $faker->addProvider(new Psn\FakerImageProvider\Image($faker));
-
generate url's
// signature Image::imageUrl(int $witdth = 640, int $height = 480): string
// https://picsum.photos/640/480 $url = $faker->imageUrl(); // https://picsum.photos/1280/720 $url = $faker->imageUrl(width: 1280, height: 720);
-
generate images
// signature Image::image( int $width = 640, int $height = 480, ?string $directory = null, ?string $extension = null ): string
// /tmp/faker_img_6672b731a5760.jpg $path = $faker->image(); // /home/user/test/faker_img_6672b731a5760.jpg $path = $faker->image(directory: '~/test'); // /tmp/faker_img_6672b731a5760.heic $path = $faker->image(extension: 'heic');