niccolomeloni / lara-football-data
Use football-data.org API in your Laravel application
Requires
- php: ^7.2
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- orchestra/testbench: ~3.0
This package is not auto-updated.
Last update: 2025-04-27 08:01:16 UTC
README
A Football Data API bridge for Laravel
Install via Composer
Install the niccolomeloni/lara-football-data
package via Composer by typing following command:
$ composer require niccolomeloni/lara-football-data
Service Provider and Facades ( Laravel 5.5 or above )
If you are using Laravel >= 5.5 that's all: this package supports Laravel new Package Discovery.
Service Provider and Facades ( Laravel 5.4 or below )
You need to add the service provider to your config/app.php
providers array:
'providers' => [ /* ... */ Niccolomeloni\LaraFootballData\ApiFootballDataServiceProvider::class, ]
Next, you may want to add the facade to your config/app.php
aliases array:
'aliases' => [ /* ... */ 'LaraFootballData' => Niccolomeloni\LaraFootballData\Facades\ApiFootballData::class, ]
Publish the configuration
Run the following command to publish the package config file:
$ php artisan vendor:publish --provider="Niccolomeloni\LaraFootballData\ApiFootballDataServiceProvider"
You should now have a config/football-data.php
file that allows you to configure the basics of this package.
Examples
Here you can see an example of how to use this package with LaraFootballData
facade:
LaraFootballData::competitions($season = ""); LaraFootballData::competition($competitionId)->teams(); LaraFootballData::competition($competitionId)->leagueTable($matchday = ""); LaraFootballData::competition($competitionId)->fixtures($timeFrame= "", $matchday = ""); LaraFootballData::fixtures($timeFrame= "", $matchday = ""); LaraFootballData::fixture($fixtureId, $head2head = ""); LaraFootballData::team($teamId)->fixtures($season = "", $timeFrame = "", $venue = ""); LaraFootballData::team($teamId)->players(); LaraFootballData::get('http://api.football-data.org/v1/...');
If you prefer to use dependency injection over facades like me, then you can inject the ApiFootballDataManager
:
namespace App\Http\Controllers; use Niccolomeloni\LaraFootballData\ApiFootballDataManager; class FooController extends Controller { protected $apiFootballDataManager; public function __construct(ApiFootballDataManager $apiFootballDataManager) { $this->apiFootballDataManager = $apiFootballDataManager; } public function competitions($season = "") { $this->apiFootballDataManager->competitions($season); } }
Documentation
Check on football-data.org API documentation.
License
Released under the MIT License, see LICENSE