woodsandwalker / faker-picture
用于FakerPHP生成图像的提供者,图像来源于 https://picsum.photos.
v1.0.0
2020-12-03 15:58 UTC
Requires
- fakerphp/faker: ^1.12
README
Faker-Picture 是用于 FakerPHP 库的提供者,可以从 picsum.photos 获取随机的图像URL。
入门指南
安装
Faker-Picture 需要 fakerphp/faker >= 1.12
composer require woodsandwalker/faker-picture
基本用法
<?php include 'vendor/autoload.php'; // use the factory to create a Faker\Generator instance $faker = Faker\Factory::create(); // add the picture provider to Faker $faker->addProvider(new WW\Faker\Provider\Picture($faker)); // generate a picture url echo $faker->pictureUrl( 640, // width (px) 480, // height (px) false, // grayscale (boolean) 0, // blur (0 = no blur, 10 = max blur) ); // 'https://picsum.photos/640/480' // generate and save picture and return filepath echo $faker->picture( null, // directory to save picture (string) 640, // width (px) 480, // height (px) true, // whether to return full path or just file name (boolean) false, // grayscale (boolean) 0, // blur (0 = no blur, 10 = max blur) ); // '/tmp/0a23be9a5ab609119e14223a22acce50.jpg'
许可证
Faker-Picture 在MIT许可证下发布。有关详细信息,请参阅附带的LICENSE文件。