adewra/traffic-scotland 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adewra/traffic-scotland

Composer 安装命令:

composer require adewra/traffic-scotland

包简介

Access Traffic Scotland's Current Incidents, Live Traffic Cameras, Unplanned Events, Roadworks, Future Roadworks, Traffic Status, Variable Message Signs and Journey Times.

README 文档

README

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.

Table of contents

Installation

Installation using composer:

composer require adewra/traffic-scotland

Laravel/Lumen version compatibility

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,

Upgrading

This package is still in Pre-release, upgrade instructions will come when the first update is officially released.

Testing

./vendor/bin/phpunit

Configuration

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

Troubleshooting hasn't been written yet.

Package features

Type Included
Configuration Yes
Views No
Blade Directives No
Commands Yes
Migrations Yes
Translations No
Middleware No
Events No
Seeds Yes

MVP & potential future functionality

  • 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

Methods

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.

Examples

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();

Lessons Learned

  • 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.

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固