Download the PHP package einar-hansen/php-football-data without Composer

On this page you can find all versions of the php package einar-hansen/php-football-data. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-football-data

PHP Football Data

Latest Version on Packagist License Total Downloads

This package gets you quickly up and going with FootballData's API using PHP. This implementation uses the V4 (latest) of the API, as of the time of writing. Read more about the API in the quickstart guide.

Installation

You can install the package via composer:

Getting Started

You should register for an account at https://www.football-data.org.

To use the service you will need create a new instance of EinarHansen\FootballData\FootballDataService::class. The service requires a client that implements Psr\Http\Client\ClientInterface::class, like for example GuzzleHttp\Client::class ('not included in the package').

Initialization

To initialize an API service you don't need to pass in any parameters. But you should provide the API Token that you recieved when registering, to avoid limited access and heavy ratelimiting.

Because of PHP PSR support and Psr17FactoryDiscovery|Psr18ClientDiscovery we do not need to pass in the implementations of the PSR contracts.

Collections

If you want to use the returned data collections as generators, then you can pass an instance of the EinarHansen\Http\Collection\LazyCollectionFactory::class class, or yor own implementation of the EinarHansen\Http\Contracts\Collection\CollectionFactory::class if you would like.

RateLimit

If you want to keep track of you rate limiting, then you should also provide an instance of \EinarHansen\Http\Contracts\RateLimit\RateLimiterState::class. By default the service will remember the attempts and remaining requests in memory, for the duration of the objects lifecycle. Below is an example using the Psr16RateLimitState that comes with the package, configured for the Free Tier.

Take a look at football-data pricing page to find the ratelimits for your Tier.

The ratelimiter will update the state with ratelimiting details from the response headers. If you have used up all the attempts, then your requests will return false.

About the resources

Initialize a service like this.

The service consists of 5 resources:

Every resource contains at least the methods all and find. all will return a collection of items, while find will grab an item by its id.

If the item you are trying to find is not found/doesn't exists, then the resource methods will return null. If you are beeing rate limited, then the methods will return false.

Area Resource

Read more about the Area Resource at the offical documentation.

Competition Resource

Read more about the Competition Resource at the offical documentation.

Match Resource

Read more about the Match Resource at the offical documentation.

Person Resource

Read more about the Person Resource at the offical documentation.

Team Resource

Read more about the Team Resource at the offical documentation.

Paginator

The Team Resource has a paginate method that returns an instance of the contract EinarHansen\Http\Contracts\Pagination\Paginator::class that keeps track of the pages and items. The Team Resource uses EinarHansen\FootballData\Pagination\TeamPaginator::class. The paginator allows you to jump between pages with the nextPage and previousPage methods.

Laravel

If you are using Laravel, then you might want to add your API Token to your .env file and reference it from you config file. You might also want to register it as a singleton in one of your service providers, for example App\Providers\AppServiceProvider::class.

Credits

This package uses code from and is greatly inspired by

Testing

This package requires PHP8.1. If you don't have this version locally or as default PHP version, then you can use the bin/develop helper script. The script is inspired by Laravel Sail, but is much simpler. To use the script you should have Docker installed. It will pull down PHP8.1 for you and allow you to run the testing commands below.

To use the script

The testing environment uses guzzlehttp/guzzle. I experienced some issues with the stream interface of the nyholm/psr7 package when loading the fixture-responses into a ResponseInterface in the testing environment, as the body stream that was created from a local file would not play nice with halaxa/json-machine package. The Nyholm package works well in production and with real responses.

About

Einar Hansen is a webdeveloper in Oslo, Norway. You'll find more information about me on my website.

License

The MIT License (MIT).


All versions of php-football-data with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
einar-hansen/http-sdk Version ^0.5.0
halaxa/json-machine Version ^1.1
psr/http-client-implementation Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package einar-hansen/php-football-data contains the following files

Loading the files please wait ....