Downloads
Stars
Version
A Football Data API bridge for Laravel
Install the niccolomeloni/lara-football-data
package via Composer by typing following command:
$ composer require niccolomeloni/lara-football-data
If you are using Laravel >= 5.5 that's all: this package supports Laravel new Package Discovery.
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,
]
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.
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);
}
}
Check on football-data.org API documentation.
Released under the MIT License, see LICENSE