askancy/howlongtobeat
Composer 安装命令:
composer require askancy/howlongtobeat
包简介
A PHP wrapper to fetch data from howlongtobeat.com with dynamic API key extraction
README 文档
README
A modern PHP wrapper to fetch game duration data from HowLongToBeat.com
Perfect for gaming apps, backlog tools, or completionist dashboards.
✨ Features
- 🔍 Search games by title
- ⏱ Get main/extra/completionist durations
- 🧩 Fetch rich game details including platforms, stats, and genres
- ⚡ Fully PSR-4, Guzzle-powered, clean and extendable
📦 Installation
Install via Composer:
composer require askancy/howlongtobeat
🚀 Usage
🔎 Search games
use Askancy\HowLongToBeat\HowLongToBeat; $hl2b = new HowLongToBeat(); $results = $hl2b->search('Lego');
Sample response:
{
"Results": [
{
"ID": "5265",
"Title": "LEGO The Lord of the Rings",
"Image": "https://howlongtobeat.com/gameimages/220px-Lego_Lord_of_the_Rings_cover.jpg",
"Summary": {
"Main Story": "10 Hours",
"Main + Extra": "16 Hours",
"Completionist": "33 Hours"
}
}
],
"Pagination": {
"Current Page": 1,
"Last Page": 4
}
}
You can also paginate:
$hl2b->search('Lego', 2);
🧠 Get game details by ID
$details = $hl2b->get(5265);
🚤 Laravel Example
You can easily integrate this wrapper into a Laravel controller or service class:
Controller example:
use Askancy\HowLongToBeat\HowLongToBeat; class GameController extends Controller { public function search(Request $request) { $query = $request->input('title'); $hl2b = new HowLongToBeat(); $results = $hl2b->search($query); return view('games.results', ['results' => $results]); } public function show($id) { $hl2b = new HowLongToBeat(); $game = $hl2b->get($id); return view('games.show', ['game' => $game]); } }
Then route it:
Route::get('/games/search', [GameController::class, 'search']); Route::get('/games/{id}', [GameController::class, 'show']);
Includes:
- Full summary and description
- Developer & publisher info
- Platform stats
- Time breakdowns (Main, 100%, Speedrun, Multiplayer, etc.)
🤝 Contributing
Got a bug or an idea?
Open an issue or send a PR — contributions are welcome!
git clone https://github.com/askancy/howlongtobeat.git composer install vendor/bin/phpunit
📜 License
Released under the MIT License.
askancy/howlongtobeat 适用场景与选型建议
askancy/howlongtobeat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 145 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「how long to beat」 「hl2b」 「howlongtobeat」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 askancy/howlongtobeat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 askancy/howlongtobeat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 askancy/howlongtobeat 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Library that let you catch fatal errors
A custom set of Symfony Form Types
Customer and Address Form Fields Manager for Magento2
Delayed Process For Laravel.
Magento 2 SMTP Extension - Configure Magento 2 to send all transactional email using Gmail, G Suite, Amazon SES, Office360, Mailgun, SendGrid, Mandrill or any other SMTP servers
Converting swiss coordinates to Lat/Long global coordinates.
统计信息
- 总下载量: 145
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-10