A package for retrieving the latest traffic information in Scotland through Traffic Scotland.
Designed primarily for the Laravel & Lumen frameworks, you can easily just drop this into any PHP project using Composer.
- Installation
- Upgrading
- Testing
- Configuration
- Troubleshooting
- Package Features
- Minimum Viable Product
- Examples
Installation using composer:
composer require adewra/traffic-scotland
Version | Status |
---|---|
4.x.x | Untested |
5.x.x | Untested |
6.x.x | Untested |
7.0 | Test Build |
For Lumen and Laravel versions earlier than 5.5
you'll also need to add the service provider in config/app.php
:
Adewra\TrafficScotland\TrafficScotlandServiceProvider::class,
This package is still in Pre-release
, upgrade instructions will come when the first update is officially released.
./vendor/bin/phpunit
To publish the configuration file run:
> php artisan vendor:publish --tag=config --tag=migrations --tag=seeds
This will copy the configuration file to config/trafficscotland.php
.
Here is an example (and the default) configuration:
'functionality' => [
'incidents' => true,
'roadworks' => [
'current' => true,
'planned' => true,
],
'events' => true,
],
'collection_methods' => [
'api' => true,
'rss_feeds' => false,
'webpage_scraping' => false,
],
'storage' => true
To run our database migrations that allow for storing of the data:
php artisan migrate --path=/packages/adewra/trafficscotland/src/migrations
Troubleshooting hasn't been written yet.
Type | Included |
---|---|
Configuration | Yes |
Views | No |
Blade Directives | No |
Commands | Yes |
Migrations | Yes |
Translations | No |
Middleware | No |
Events | No |
Seeds | Yes |
- Incidents
- Roadworks (Current & Planned)
- Events (& Venues)
-
Status/Congestion - Traffic Cameras
- Queues
- Park and Ride
- Bulletins
- Weather Incidents
- Weather Stations
- Police Travel Warnings
- Variable Message Signs
- Highways England
- News
- Gritters
The preferred method for obtaining information is through Traffic Scotland's API that is utilised by the mobile version of their website.
Alternative methods include use of Datex II Service, RSS Feeds or through scraping the web pages.
Retrieving Current Incidents
$incidents = TrafficScotland::incidents();
php artisan trafficscotland:incidents
php artisan tinker
>>> Adewra\TrafficScotland\Incident::all();
Retrieving Roadworks
$roadworks = TrafficScotland::roadworks(true, true);
php artisan trafficscotland:roadworks
php artisan tinker
>>> Adewra\TrafficScotland\Roadwork::all();
Retrieving Events
$roadworks = TrafficScotland::events();
php artisan trafficscotland:events
php artisan tinker
>>> Adewra\TrafficScotland\Event::all();
>>> Adewra\TrafficScotland\Venue::all();
- My original choice of HTTP client Goutte isn't able to handle Traffic Scotland's website's javascript based navigation and as such, I should have gone with Selenium 2 from the beginning. Using Behat's Mink I am able to easily switch between both.