badges/poser
Composer 安装命令:
composer require badges/poser
包简介
Poser, add badges on your readme..
关键字:
README 文档
README
This is a php library that creates badges like and
and
,
according to Shields specification.
This library is used by https://poser.pugx.org
Dependencies
- PHP 8.1 or higher
- GD extension
you can still use the library with lower PHP versions, using the old releases
Use as command
1. Create a project
composer create-project badges/poser ln -s poser/bin/poser /usr/local/bin/poser
2. Launch the command
Create an image
poser license MIT blue -p "license.svg"
Flush an image
poser license MIT blue
Choose a different style
poser license MIT blue -s "for-the-badge"
The available styles are plastic, flat, flat-square, for-the-badge, and social.
You can also use the provided Docker Compose services:
docker compose run --rm php82 bin/poser license MIT blue docker compose run --rm php83 bin/poser license MIT blue -p "license.svg" docker compose run --rm php83 bin/poser license MIT blue -s "plastic" -p "license-plastic.svg"
Usage as library
1. Add to composer dependencies
composer require badges/poser
2. Use in your project as lib
use PUGX\Poser\Render\SvgPlasticRender; use PUGX\Poser\Poser; $render = new SvgPlasticRender(); $poser = new Poser([$render]); echo $poser->generate('license', 'MIT', '428F7E', 'plastic'); // or echo $poser->generateFromURI('license-MIT-428F7E.svg?style=plastic'); // or echo $poser->generateFromURI('license-MIT-428F7E?style=plastic'); // or $image = $poser->generate('license', 'MIT', '428F7E', 'plastic'); echo $image->getStyle();
The allowed styles are: plastic, flat, flat-square, for-the-badge, and social.
Badge customization
Badges generated from a URI support these query string options:
| Option | Description |
|---|---|
style |
Badge style: plastic, flat, flat-square, for-the-badge, or social. |
labelColor |
Color for the left side of the badge. Accepts named colors, 6-digit hex, or 3-digit hex. |
logo |
Optional logo as an image URL, data:image/... URI, or SVG path data. |
logoColor |
Color used when logo is SVG path data. Defaults to white. Accepts named colors, 6-digit hex, or 3-digit hex. |
Examples:
echo $poser->generateFromURI('license-MIT-blue.svg?style=social'); echo $poser->generateFromURI('build-passing-brightgreen.svg?labelColor=555'); echo $poser->generateFromURI('github-stars-333.svg?style=social&logo=https%3A%2F%2Fexample.com%2Fgithub.svg'); $logo = rawurlencode('M12 2L2 22h20L12 2z'); echo $poser->generateFromURI('php-8.4-777.svg?logoColor=blueviolet&logo=' . $logo);
When these options are used in a URL, encode reserved characters. In particular, encode # as %23, and encode full image/data URLs passed as logo.
The CLI currently exposes style selection with --style; labelColor, logo, and logoColor are available through URI-based generation.
Custom SVG templates
Since v3.4.0, SVG templates use vendorStartX and valueStartX instead of the old vendorStartPosition and valueStartPosition placeholders. If you maintain custom templates, update them before upgrading:
- {{ vendorStartPosition }} - {{ valueStartPosition }} + {{ vendorStartX }} + {{ valueStartX }}
These values are the text center positions multiplied by 10 and are intended to be used with transform="scale(.1)", as the bundled templates do.
The renderer also provides these optional template placeholders: vendorUpper, valueUpper, vendorTextLength, valueTextLength, vendorWidthMinus1, valueWidthMinus1, valueRectX, separatorX, and logoElement.
Examples (generated with make doc-images)
Encoding
Dashes -- → - Dash
Underscores __ → _ Underscore
_ or Space → Space
More
For more info please see the behat features and the examples in the php-spec folder
Why a composer badge?
Not only because all the other languages already have it, but having the latest stable release in the readme could save time.
Contributing
Active contribution and patches are very welcome.
Please refer to CONTRIBUTING
Docker development
You can use the env var CONTAINER to run the tests in a specific PHP version. The default version if CONTAINER is omitted is php83.
1. Setup your Docker environment
CONTAINER=php83 make setup
2. Run the tests
CONTAINER=php83 make tests
3. Run the tests for all PHP versions
make matrix-tests
License
badges/poser 适用场景与选型建议
badges/poser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 77.85k 次下载、GitHub Stars 达 144, 最近一次更新时间为 2014 年 06 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「composer」 「pin」 「badge」 「packagist」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 badges/poser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 badges/poser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 badges/poser 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Aktive-Merchant provides a common interface to process payments using multiple gateways.
Add gamification in laravel app with reputation point and badges support
Laravel Token Builder
Photo Rest Bundle for symfony2
Validates Zip/Postal Codes for any country and provides each country's localized name for their version of the Zip/Postal code (CEP, PLZ, PIN code, Eircode, NPA, CAP, ZIP code, etc.).
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
统计信息
- 总下载量: 77.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 146
- 点击次数: 29
- 依赖项目数: 9
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-06-29