PHP Classes

PHP Premier League API: Retrieve information about the UK Premier League

Recommend this page to a friend!
  Info   View files Example   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 135 All time: 9,258 This week: 124Up
Version License PHP version Categories
premier-league-api 1.0MIT/X Consortium ...5.3PHP 5, Games, Web services
Description 

Author

This package is specific mainly for applications used in United Kingdom .

This package can retrieve information about the UK Premier League.

It can send the HTTP requests to the Premier League Web site API to retrieve several types of details.

Currently it can retrieve the league teams, get single team details, get the details of matches, get the next match of a team, and get the standings of teams.

Innovation Award
PHP Programming Innovation award nominee
March 2016
Number 13


Prize: PHP Tools for Visual Studio Personal license
Many fans are interested in following UK Premier League of football.

This class can retrieve all the details of the games and rankings of this league using the UK Premier League API.

Manuel Lemos
Picture of vince
  Performance   Level  
Name: vince <contact>
Classes: 1 package by
Country: United Kingdom
Age: ???
All time rank: 4304189 in United Kingdom
Week rank: 312 Up8 in United Kingdom Up
Innovation award
Innovation award
Nominee: 1x

Example

<?php
/** utilise composor to autoload dependancies **/
require 'vendor/autoload.php';

use
Vlowe\PremierLeague\PremierLeague;

try {
   
   
$epl = new PremierLeague();
   
   
// returns raw data
    //$data = $epl->getData();
   
    // returns current season: "2015-2016"
    //$data = $epl->getSeason();
   
    // returns all team details
   
$data = $epl->getTeams();
   
   
// returns single team details
    //$data = $epl->getTeam('Liverpool');
   
    // returns all matches raw data
    //$data = $epl->getMatches();
   
    // returns all matches for team, inc club badges
    //$data = $epl->getMatches('Liverpool');
   
    // returns teams next match details
    //$data = $epl->getNextMatch('Liverpool');
   
    // returns all current standing details
    //$data = $epl->getStandings();
   
    // returns teams current standing details
    //$data = $epl->getStanding('Liverpool');
} catch (Exception $e) {
   
    die(
'Fatal error: ' . $e->getMessage());
}
?>
<!doctype html>
<html lang="en">
    <head>
        <title>PHP Premier League</title>
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-7s5uDGW3AHqw6xtJmNNtr+OBRJUlgkNJEo78P4b0yRw= sha512-nNo+yCHEyn0smMxSswnf/OnX6/KwJuZTlNZBjauKhTK0c+zT+q5JOCx0UFhXQ6rJR9jg6Es8gPuD2uZcYDLqSw==" crossorigin="anonymous">
    </head>
    <body>
        <nav class="navbar">
          <div class="container">
            <div class="navbar-header">
              <a class="navbar-brand" href="#">PHP Premier League Example</a>
            </div>
          </div>
        </nav>
        <div class="container">
            <div class="row">
                <div class="col-md-7">
                    <h3>Standings</h3>
                    <table class="table table-hover col-md-4">
                        <tr>
                            <th>POS</th>
                            <th></th>
                            <th>Team</th>
                            <th>Played</th>
                            <th>Points</th>
                            <th>Next game</th>
                        </tr>
                            <?php foreach($data as $team) { ?>
<tr>
                                <td><?php echo $team['standing'] ?></td>
                                <td><img src='<?php echo $team['badge'] ?>' height='20px'/></td>
                                <td><?php echo $team['name'] ?></td>
                                <td><?php echo $team['played'] ?></td>
                                <td><?php echo $team['points'] ?></td>
                                <td>
                                    <img src='<?php echo $epl->getNextMatch($team['name'])['homeTeamBadge']; ?>' height='20px'/>
                                     vs
                                    <img src='<?php echo $epl->getNextMatch($team['name'])['awayTeamBadge']; ?>' height='20px'/>
                                </td>
                            </tr>
                            <?php } ?>
</table>
                </div>
            </div>
        </div>
    </body>
</html>


Details

PHP Premier League API

Introduction

This is a PHP package for extracting data from http://www.premierleague.com/

You can get team, match and league standings data to be used in your own application.

Usage

  • get all data received from JSON api

    getData()

  • get current season: returns "2015-2016"

    getSeason()

  • get all team details, including badge and standing details

    getTeams()

  • get the team details for the specified team, including badge and standing details

    getTeam('Liverpool')

  • get all matches raw data

    getMatches()

  • get matches data for the specified team, including badges for home and away teams

    getMatches('Liverpool')

  • get teams next match details, including badges for home and away teams

    getNextMatch('Liverpool')

  • get the current league standings

    getStandings()

  • get the current league standings for the specified team

    getStanding('Liverpool')

Example

Example usage

An example of the usage is provided in this repository.


  Files folder image Files  
File Role Description
Files folder imagesrc (2 files)
Files folder imagetests (2 files)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file example.php Example Example script
Accessible without login Image file example.png Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file PremierLeague.php Class Class source
  Plain text file Transport.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file PremierLeagueTest.php Test Unit test script
  Accessible without login Plain text file TransportTest.php Test Unit test script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:135
This week:0
All time:9,258
This week:124Up