michaelcrowcroft/espn-laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

michaelcrowcroft/espn-laravel

Composer 安装命令:

composer require michaelcrowcroft/espn-laravel

包简介

Fluent Laravel SDK for ESPN APIs using Saloon

README 文档

README

Installation

You can install the package via composer:

composer require michaelcrowcroft/espn-laravel

(Optional) You can publish the config file with:

php artisan vendor:publish --tag="espn-laravel-config"

Usage

use Espn\Facades\Espn;

// Athletes (Core v3)
$athletes = Espn::athletes()->page(page: 1, limit: 20000);
$mahomes  = Espn::athletes()->get(15864); // Example athlete ID

// Fantasy players (reads v3)
$playersAllOn     = Espn::fantasy()->allOn(2024); // view=allon
$konaInfo         = Espn::fantasy()->konaPlayerInfo(2024, limit: 2000);
$customFilter     = Espn::fantasy()->players(
    2024,
    'mLiveScoring',
    ['games' => ['limit' => 2000]] // becomes X-Fantasy-Filter header
);

// Saloon Response usage
$json = $athletes->json();

Fluent Helpers for Fantasy (easy website stats)

use Espn\Facades\Espn;

// Top actual scorers (weekly or overall best available)
$topWeekly = Espn::fantasy()->topScorers(year: 2024, week: 1, take: 25);

// Top projected scorers (weekly or best available projection)
$topProjected = Espn::fantasy()->topProjected(year: 2024, week: 2, take: 25);

// Trending by ownership change (best-effort from kona_player_info)
$trendingAdds  = Espn::fantasy()->trendingAdds(year: 2024, take: 25);
$trendingDrops = Espn::fantasy()->trendingDrops(year: 2024, take: 25);

// Each returns an array of simple player summaries:
// [
//   ['id' => 123, 'name' => 'Player Name', 'team' => 'KC', 'position' => 'TE', 'points' => 27.8],
//   ...
// ]

// Fluent query builder for more control
$query = Espn::fantasy()
    ->query(2024)
    ->positions(['RB', 'WR'])   // simple post-filter by position
    ->scoringPeriod(1)          // weekly focus
    ->limit(1500);              // X-Fantasy-Filter games.limit

$topRbwrs = $query->topScorers(take: 20);

Notes:

  • The helpers use common ESPN views (mLiveScoring and kona_player_info) and return simple arrays for direct UI use.
  • Trending methods are based on ownership change fields when provided by the API. If a dataset lacks ownership deltas, results may be empty.
  • For full control, use Espn::fantasy()->players(...) with a custom X-Fantasy-Filter.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-29