philipnewcomer/linkify-tracking 问题修复 & 功能扩展

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

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

philipnewcomer/linkify-tracking

最新稳定版本:2.0.0

Composer 安装命令:

composer require philipnewcomer/linkify-tracking

包简介

Linkifies package tracking numbers for DHL, FedEx, UPS, and USPS

README 文档

README

Linkifies package tracking numbers for DHL, FedEx, Royal Mail (UK), UPS, and USPS.

Installation

composer require philipnewcomer/linkify-tracking

Usage

First instantiate an instance of the library:

$linkifyTracking = new PhilipNewcomer\LinkifyTracking\LinkifyTracking;

Get the tracking URL for a single tracking number

$linkifyTracking->getLinkUrl('12345678901234567890');

Result:

https://tools.usps.com/go/TrackConfirmAction?tLabels=12345678901234567890

Get the link data for a single tracking number

$linkifyTracking->getLinkData('12345678901234567890');

Result:

[
    'carrier' => 'USPS',
    'url' => 'https://tools.usps.com/go/TrackConfirmAction?tLabels=12345678901234567890'
]

Convert all tracking numbers in the given content to HTML links

$content = '
Here is a tracking number: 12345678901234567890
And another tracking number: 12345678901234567890
';
$linkifyTracking->linkify($content)

Result:

Here is a tracking number: <a href="https://tools.usps.com/go/TrackConfirmAction?tLabels=12345678901234567890">12345678901234567890</a>
And another tracking number: <a href="https://tools.usps.com/go/TrackConfirmAction?tLabels=12345678901234567890">12345678901234567890</a>

Configuration

Configuration arguments may be passed to the LinkifyTracking constructor.

The following arguments may be provided:

  • linkAttributes: An array of attributes which should be added to the generated HTML links

Example:

$linkifyTracking = new PhilipNewcomer\LinkifyTracking\LinkifyTracking([
    'linkAttributes' => [
        'class' => 'tracking-link',
        'target' => '_blank'
    ]
]);

Credits

Tracking number regular expressions for DHL, FedEx, UPS, and USPS are taken from https://github.com/darkain/php-tracking-urls.

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2018-05-24