adminui/fakerphp-picsum-images

使用 picsum.photos 的 fakerphp 替代图像提供程序

v1.0.0 2022-10-02 14:48 UTC

This package is not auto-updated.

Last update: 2024-09-16 22:35:13 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

介绍

使用 picsum.photos 作为图像提供程序的 fakerphp 的替代方案

此包已从 mmo/faker-images 分支,用于 fzaninotto/faker(已弃用 ~ 2020年10月)。

资源

安装

您可以通过 composer 在 dev 依赖部分安装此包

composer require --dev adminui/fakerphp-picsum-images

用法

$faker = \Faker\Factory::create();
$faker->addProvider(new \AdminUI\FakerPicsumImages\FakerPicsumImagesProvider($faker));

// return a string that contains a url like 'https://picsum.photos/800/600/'
$faker->imageUrl($width = 800, $height = 600); 

// download a properly sized image from picsum into a file with a file path like '/tmp/13b73edae8443990be1aa8f1a483bc27.jpg'
$filePath= $faker->image($dir = '/tmp', $width = 640, $height = 480);

此外,还有一些其他选项

致谢

许可证

MIT 许可证(MIT)。有关更多信息,请参阅许可证文件