swatty007/faker-image-generator
Composer 安装命令:
composer require swatty007/faker-image-generator
包简介
Placeholder Image Generator for FakerPHP
README 文档
README
Generator of placeholder-type images using GD for fzaninotto/Faker to quickly generate fake images within your application or tests, without the need to rely on external services.
This is a fork from bruceheller/images-generator as that package seems to not be actively maintained anymore.
Installation
You can install the package via composer:
composer require swatty007/faker-image-generator
Configuration
After installing the package you can publish the configuration file via:
php artisan vendor:publish --provider="Swatty007\FakerImageGenerator\FakerImageGeneratorServiceProvider"
It contains some optional configuration parameters and is fully documented.
The configuration allows you to define some global image properties which will be shared across all Generator Instances. This is an addition to the original package to make is easier to share a similar style throughout your application.
Usage
Use the FakerImageGenerationProvider class in combination with Faker to produce new images:
$faker = Factory::create(); $imageGenerator = new FakerImageGenerationProvider($faker); $image = $faker->imageGenerator();
It will generate a black png picture of 640*480 pixels inside your temp directory (if available)
and return the full path of the picture like this: '/tmp/13b73edae8443990be1aa8f1a483bc27.png'.
Parameters
The imageGenerator() method allows you to define rendering options on a per element basis,
those options are identical to your configuration properties and will allow you quickly generate unique images.
Examples:
$faker->imageGenerator();
Will generate a 640x480 black png picture with the text '640x480' in white.
$faker->imageGenerator('img', 640, 480, 'png', true, 'Faker', '#0018ff', '#ffd800');
Will generate a 640x480 blue png picture with the text 'Faker' in yellow inside an img directory of your project and return the full path such as 'img/f523f8bec6ed65fb1d63ae8d09850f9c.png' like this:
More complex example using the power of Faker:
$faker->imageGenerator('img', $faker->numberBetween(600, 800), $faker->numberBetween(400, 600), 'jpg', true, $faker->word, $faker->hexColor, $faker->hexColor);
Will return a jpeg of a random color picture with a width between 600 and 800 pixels, height between 400 and 600 pixels, with a random word written in a random color!
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
TODO
As this is mainly a fork of the existing package, to get it running within modern applications, its future development plans could apply to this package as well. However, its current functionality fulfills my needs. Nonetheless, some TODOs remain & are open for pull requests 🧐
- Improve Readme
- Transition to GitHub Actions
- Improve & Extend existing tests!
- Add support for ImageMagick and/or GraphicsMagick for faster generation of pictures.
Otherwise, any suggestion is welcome! You can fork this project and submit your PR :)
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email info@martin-niehoff.de instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
The Roboto font file included in this project is under Apache Licence 2.0 as mentioned on the Roboto repository.
swatty007/faker-image-generator 适用场景与选型建议
swatty007/faker-image-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.94k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「faker」 「fixtures」 「data」 「images-generator」 「imagesgenerator」 「swatty007」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 swatty007/faker-image-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 swatty007/faker-image-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 swatty007/faker-image-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Testing object factory for PHP
Testing object factory for PHP
Adds the EDTF data type to Wikibase
Plugin to compare fixtures with live DB tables
A simple library that allows transform any kind of data to native php data or whatever
统计信息
- 总下载量: 1.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-24


