apsonex/font
Composer 安装命令:
composer require apsonex/font
包简介
Font
README 文档
README
A simple PHP package to manage and search fonts from multiple providers. Currently supports the Bunny Fonts provider with an easy way to list, search, and filter fonts.
Features
- List fonts with pagination
- Search fonts by keyword
- Find fonts by key(s), family(ies), and type
- Extensible with multiple font providers
Installation
composer require apsonex/font-manager
Usage
use Apsonex\Font\Font; // Instantiate the font manager $fontManager = Font::make(); // Select Bunny provider $fontManager->bunny(); // List fonts (paginated) $response = $fontManager->list(limit: 20, page: 1); foreach ($response->fonts as $font) { echo $font->family . PHP_EOL; } // Search fonts by keyword $searchResponse = $fontManager->search('abo', limit: 20, page: 1); // Find font by a single key $font = $fontManager->findByKey('abel'); // Find fonts by multiple keys $response = $fontManager->findByKeys(['abel', 'abeezee'], limit: 10); // Find fonts by family $response = $fontManager->findByFamily('Abel', limit: 10); // Find fonts by multiple families $response = $fontManager->findByFamilies(['Abel', 'Aboreto'], limit: 10); // Find fonts by type (e.g., 'sans-serif') // Use limit -1 to fetch all matches $response = $fontManager->findByType('sans-serif', limit: -1);
API Reference
Font Manager (Apsonex\Font\Font)
- make(): static — Create a new instance
- bunny(): static — Use Bunny font provider
- useProvider(FontProviderInterface $provider): static — Use a custom font provider
- list(int $limit = 20, int $page = 1): FontResponse — List fonts paginated
- search(string $keyword, int $limit = 20, int $page = 1): FontResponse — Search fonts by keyword
- findByKey(string $key): ?FontDTO — Find a single font by key
- findByKeys(array $keys, int $limit = 20): FontResponse — Find fonts by keys
- findByFamily(string $family, int $limit = 20): FontResponse — Find fonts by family
- findByFamilies(array $families, int $limit = 20): FontResponse — Find fonts by families
- findByType(string $type, int $limit = -1): FontResponse — Find fonts by category/type
FontDTO (Apsonex\Font\FontDTO)
- Represents a single font object with these properties:
- key (string): Unique font key
- provider (string): Provider name
- category (string): Font category (e.g., sans-serif)
- family (string): Font family name
- urlString (string): CSS font string identifier
The FontDTO class represents a single font item with key metadata used across the package.
| Property | Type | Description | Example |
|---|---|---|---|
key |
string | Unique identifier for the font | "abeezee" |
provider |
string | The font provider source | "bunny" |
category |
string | Font category/type (e.g., serif, sans-serif) | "sans-serif" |
family |
string | The font family name | "ABeeZee" |
urlString |
string | A URL-friendly CSS font string used for loading | "abeezee:400,400i" |
use Apsonex\Font\FontDTO; // Creating a FontDTO object (usually returned from provider methods) $font = new FontDTO( key: 'abeezee', provider: 'bunny', category: 'sans-serif', family: 'ABeeZee', urlString: 'abeezee:400,400i' ); // Accessing properties echo "Font Key: " . $font->key . PHP_EOL; // Output: abeezee echo "Provider: " . $font->provider . PHP_EOL; // Output: bunny echo "Category: " . $font->category . PHP_EOL; // Output: sans-serif echo "Family: " . $font->family . PHP_EOL; // Output: ABeeZee echo "CSS URL String: " . $font->urlString . PHP_EOL; // Output: abeezee:400,400i
FontResponse (Apsonex\Font\FontResponse)
- Paginated font response containing:
- fonts (array of FontDTO)
- total (int) — total matched fonts
- limit (int) — items per page
- page (int) — current page number
Testing
This package uses Pest PHP for testing.
./vendor/bin/pest
Extending with other Providers
You can implement your own provider by creating a class that implements:
use Apsonex\Font\Contracts\FontProviderInterface; class YourProvider implements FontProviderInterface { public function list(int $limit, int $page): FontResponse { /*...*/ } public function search(string $keyword, int $limit, int $page): FontResponse { /*...*/ } public function findByKey(string $key): ?FontDTO { /*...*/ } // Implement other methods from interface... }
Then register it:
$fontManager->useProvider(new YourProvider());
License
MIT License © Apsonex Inc
Contributing
Feel free to open issues and pull requests!
apsonex/font 适用场景与选型建议
apsonex/font 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 974 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「font」 「apsonex」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 apsonex/font 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 apsonex/font 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 apsonex/font 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
FontAwesome5 for Magento2
PHP SVG font parser
An asset bundle for Font Awesome icons with Bootstrap 4.
Add a service icon link as a contao content element.
SDL TTF FFI bindings for the PHP language
PHP helpers
统计信息
- 总下载量: 974
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-26