, (*1)
A Football Data API bridge for Laravel, (*2)
Install via Composer
Install the niccolomeloni/lara-football-data
package via Composer by typing following command:, (*3)
$ 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., (*4)
Service Provider and Facades ( Laravel 5.4 or below )
You need to add the service provider to your config/app.php
providers array:, (*5)
'providers' => [
/* ... */
Niccolomeloni\LaraFootballData\ApiFootballDataServiceProvider::class,
]
Next, you may want to add the facade to your config/app.php
aliases array:, (*6)
'aliases' => [
/* ... */
'LaraFootballData' => Niccolomeloni\LaraFootballData\Facades\ApiFootballData::class,
]
Publish the configuration
Run the following command to publish the package config file:, (*7)
$ 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., (*8)
Examples
Here you can see an example of how to use this package with LaraFootballData
facade:, (*9)
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
:, (*10)
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., (*11)
License
Released under the MIT License, see LICENSE, (*12)