thatobabusi/laravel-lastfm
Composer 安装命令:
composer require thatobabusi/laravel-lastfm
包简介
Last.fm API client for Laravel 7-13
README 文档
README
📦 Packagist · 📚 Docs · 📜 Changelog · 🔗 Last.fm API
A modern, type-safe Last.fm API client for Laravel 7-13. Built with fluent interfaces, full type hints, and dependency injection support.
Documentation
Features
API Integration
- Fluent interface for all major Last.fm API endpoints
- User statistics and track information retrieval
- Weekly and overall chart data
- Now-playing track detection
Laravel Integration
- Auto-registration via package discovery (Laravel 5.5+)
- Dependency injection support
- Configuration publishing
- Service provider binding
Developer Experience
- Full type hints and strict mode
- Chainable query builder pattern
- Per-request period and limit filtering
- Tested against Laravel 7, 8, 9, 10, 11, 12, and 13
Requirements
- PHP >= 7.4
- Laravel >= 7.0
- Guzzle HTTP Client 6 or 7
Installation
Install via Composer:
composer require thatobabusi/laravel-lastfm
Configuration
Add your Last.fm API key to your .env file:
LASTFM_API_KEY=your_api_key_here
Or publish and customize the configuration file:
php artisan vendor:publish --provider="Thatobabusi\LaravelLastFm\LastfmServiceProvider"
For Laravel versions prior to 5.5, manually register the service provider in config/app.php:
'providers' => [ ... Thatobabusi\LaravelLastFm\LastfmServiceProvider::class, ];
Usage
Basic Example
Inject the Lastfm class into your controller or service:
use Thatobabusi\LaravelLastFm\Lastfm; public function topAlbums(Lastfm $lastfm) { $albums = $lastfm->userTopAlbums('username')->get(); return view('albums', compact('albums')); }
Available Methods
User Statistics
userTopAlbums(string $username)— Get user's top albumsuserTopArtists(string $username)— Get user's top artistsuserTopTracks(string $username)— Get user's top tracksuserInfo(string $username)— Get user profile informationuserRecentTracks(string $username)— Get user's recent tracks
Real-time Data
nowListening(string $username)— Get currently playing track (orfalse)
Weekly Charts
userWeeklyTopAlbums(string $username, DateTime $startdate)— Get weekly top albumsuserWeeklyTopArtists(string $username, DateTime $startdate)— Get weekly top artistsuserWeeklyTopTracks(string $username, DateTime $startdate)— Get weekly top tracksuserWeeklyChartList(string $username)— Get list of available weekly charts
Filtering Results
Chain methods to customize your queries:
use Thatobabusi\LaravelLastFm\Constants; // Filter by time period $lastfm->userTopAlbums('username') ->period(Constants::PERIOD_MONTH) ->get(); // Limit results $lastfm->userTopAlbums('username') ->limit(5) ->get(); // Paginate through results $lastfm->userTopAlbums('username') ->limit(10) ->page(2) ->get();
Time Periods
Use these constants with the ->period() method:
Constants::PERIOD_WEEK // Last 7 days Constants::PERIOD_MONTH // Last month Constants::PERIOD_3_MONTHS // Last 3 months Constants::PERIOD_6_MONTHS // Last 6 months Constants::PERIOD_YEAR // Last 12 months Constants::PERIOD_OVERALL // All time
Getting an API Key
Create a Last.fm account and generate an API key at: http://www.last.fm/api/account/create
API Documentation
For complete Last.fm API reference, see: http://www.last.fm/api
Testing
Copy phpunit.xml.dist to phpunit.xml and configure your Last.fm API key, then run:
composer test
🤝 Contributing
Issues and pull requests are welcome for bug fixes, features, and documentation.
Please see CONTRIBUTING.md and CODE OF CONDUCT for details.
🔒 Security
If you discover a security vulnerability, please email thatobabusi@yahoo.com instead of using the issue tracker.
📜 License
Open-sourced software licensed under the MIT license.
Built with ❤️ for the Laravel community.
thatobabusi/laravel-lastfm 适用场景与选型建议
thatobabusi/laravel-lastfm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 11 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「client」 「service provider」 「laravel」 「lastfm」 「last.fm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 thatobabusi/laravel-lastfm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thatobabusi/laravel-lastfm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 thatobabusi/laravel-lastfm 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A fast and intuitive dependency injection container.
A PSR-7 compatible library for making CRUD API endpoints
Registry service.
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-06