nkl-kst/the-sports-db
Composer 安装命令:
composer require nkl-kst/the-sports-db
包简介
PHP library to get sports data from TheSportsDB (https://www.thesportsdb.com)
关键字:
README 文档
README
An easy-to-use PHP library to get data from https://www.thesportsdb.com.
Features
- Get data for lists, livescores, lookups, schedules, searches or video highlights
- Get results in serialized classes
- Use your own API key
- Throttle long-running scripts
- Use PSR-4 autoloading
- Supports PHP 7.4+
This library uses Semantic Versioning.
Installation
Install this PHP library with Composer.
> composer require nkl-kst/the-sports-db
Usage
Get data
Get sports data from TheSportsDB.
// You need to load the Composer autoload file somewhere in your code before require_once 'vendor/autoload.php'; use NklKst\TheSportsDb\Client\ClientFactory; // Create a client $client = ClientFactory::create(); // Get soccer livescores $livescores = $client->livescore()->now('Soccer'); echo $livescores[0]->strProgress; // Get video highlights $highlights = $client->highlight()->latest(); echo $highlights[0]->strVideo; // Get next events for Liverpool FC $events = $client->schedule()->teamNext(133602); echo $events[0]->strEvent;
See integration tests for examples of all documented API calls.
Use your API key
Use your own Patreon API key.
use NklKst\TheSportsDb\Client\ClientFactory; // Set an API key $client = ClientFactory::create(); $client->configure()->setKey('YOUR_API_KEY');
Throttle requests
You are advised to do no more than 100 requests per minute to TheSportsDB API (the hard limit is two requests per second). If you have long-running scripts to gather many data, please consider to use the built-in rate limiter.
use NklKst\TheSportsDb\Client\ClientFactory; // Use the default rate limit of 100 requests per minute $client = ClientFactory::create(); $client->configure()->setRateLimiter(); // Do your requests as usual // You can unset the rate limiter later $client->configure()->unsetRateLimiter();
As this library uses the Symfony Rate Limiter Component, it's possible to use a custom rate limit mechanism. Please consult the Symfony documentation for more information.
Known issues
- Livescores for v1 are not supported.
- If you are getting an exception like
JSON property "foo" in class "Bar" must not be NULL, then there is an entity attribute which should be nullable. Please open a new issue in this case.
Feedback
If you have any problems or questions, feel free to open an issue or a pull request.
Developer notes
Run tests and code checks.
# Unit tests > composer test-unit # Integration tests (API calls, Patreon key required) > PATREON_KEY=<YOUR_PATREON_KEY> composer test-integration # On Windows use 'set PATREON_KEY=<YOUR_PATERON_KEY>' before running the tests # Analyze code (static analysis) > composer analyze-code # Check code (coding standards) > composer check-code
License: MIT
See LICENSE.
nkl-kst/the-sports-db 适用场景与选型建议
nkl-kst/the-sports-db 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.21k 次下载、GitHub Stars 达 29, 最近一次更新时间为 2020 年 12 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「library」 「TheSportsDB」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nkl-kst/the-sports-db 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nkl-kst/the-sports-db 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nkl-kst/the-sports-db 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
Alfabank REST API integration
CakePHP Bitly Plugin
统计信息
- 总下载量: 1.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 29
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-30