承接 ccharz/faker-gd-image 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ccharz/faker-gd-image

最新稳定版本:v1.0.0

Composer 安装命令:

composer require ccharz/faker-gd-image

包简介

FakerPHP Provider to create random images with the help of gd

README 文档

README

FakerPHP (https://fakerphp.github.io/) Provider to create random images with the help of gd. This provider uses the same function signature as the build-in image provider image function (https://fakerphp.github.io/formatters/image/#image_1) so it can be used as a direct replacement

Installation

composer require ccharz/faker-gd-image

Usage

$faker = \Faker\Factory::create();
$faker->addProvider(new \Faker\Provider\GdImage($faker));

// Stores a generated image in the systems tmp folder
$image_path = $faker->gdImage($dir = null, $width = 640, $height = 480);

// Returns a gd image object
$gd_image = $faker->gdImageObject($width = 640, $height = 480, $text = 'Test', $background_color = '6A6A6A');

Usage in Laravel

To use it in laravel factories you could add this to the AppServiceProvider.php:

/**
 * Register any application services.
 *
 * @return void
 */
public function register()
{
    $this->app->singleton(\Faker\Generator::class, function () {
        $faker = \Faker\Factory::create();
        $faker->addProvider(new \Faker\Provider\GdImage($faker));
        return $faker;
    });
}

Acknowledgment

This project uses https://github.com/googlefonts/opensans which is published under the SIL Open Font License https://github.com/googlefonts/opensans/blob/main/OFL.txt

统计信息

  • 总下载量: 1.6k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-13