Download the PHP package risan/sl without Composer
On this page you can find all versions of the php package risan/sl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package sl
Short Description HTTP client library for sl.se, Stockholm public transportation API.
License MIT
Homepage https://github.com/risan/sl
Informations about the package sl
Stockholm Pulic Transport
PHP HTTP client library for communicating with sl.se—a Stockholm public transportation website.
Table of Contents
- Dependencies
- Installation
- Basic Usage
- Search for Station
- Find Departures
- Bus Departures
- Train Departures
- Metro Departures
- Tram Departures
- Light Rail Departures
- Ship Departures
Dependencies
This package relies on the following libraries to work:
All above dependencies will be automatically downloaded if you are using Composer to install this package.
Installation
To install this library using Composer, simply run the following command inside your project directory:
Or you may also add risan\sl
package into your composer.json
file like so:
And don't forget to run the following composer command to install this library:
Basic Usage
Here is some basic example to use this library:
Search for Station
To search for a station, you may use the searchStation()
method:
For example, if you'd like to find all stations that match the central
word, then your code will look like this:
The searchStation()
method will automatically perform a HTTP request to sl.se to search for stations that match the given $query
. This method will return an instance of Sl\Collections\StationCollection
class, which contains a collection of Sl\Station
instances.
The StationCollection
class itself is a subclass of Illuminate\Support\Collection
, so you may leverage the powerful feature of Laravel's collection.
Find Departures
You may also find departures from a specific station using departuresFrom()
method:
This method will perform a HTTP request to sl.se website in order to find a list of departures for a given $station
. Note that this method requires an argument that must be instance of Sl\Station
class.
For example, if you need to find all departures from Slussen
station, you can do the following:
The $departures
will be an instance of Sl\Collections\DepartureCollection
which hold a collection of Sl\Departure
instances. The DepartureCollection
is also a subclass of Illuminate\Support\Collection
.
Bus Departures
To filter only the bus departures, call busses
method:
Train Departures
To filter only the train (pendeltåg) departures, call trains()
method:
Metro Departures
To filter only the metro (tunnelbana) departures, call metros()
method:
Tram Departures
To filter only the tram (spårvagn) departures, call trams()
method:
Light Rail Departures
To filter only the light rail (lokalbana) departures, call lightRails()
method:
Ship Departures
To filter only the ship or boat departures, call ships()
method: