定制 setono/coolrunner-php-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

setono/coolrunner-php-sdk

最新稳定版本:v1.1.0

Composer 安装命令:

composer require setono/coolrunner-php-sdk

包简介

Consume the CoolRunner API v3 with this PHP SDK

README 文档

README

Latest Version Software License Build Status Code Coverage Mutation testing

Consume the CoolRunner API v3 in PHP.

Installation

composer require setono/coolrunner-php-sdk

Usage

<?php

use Setono\CoolRunner\Client\Client;
use Setono\CoolRunner\DTO\Collection;
use Setono\CoolRunner\DTO\Servicepoint;

require_once '../vendor/autoload.php';

$client = new Client('USERNAME', 'TOKEN');

$servicepoints = $client
    ->servicepoints()
    ->find('gls', 'DK', 'Stigsborgvej 60 4. th.', '9400', 'Nørresundby')
;

foreach ($servicepoints as $servicepoint) {
    echo $servicepoint->name . "\n";
    echo $servicepoint->address->street . "\n";
    echo $servicepoint->address->zipCode . ' ' . $servicepoint->address->city . "\n";
    echo $servicepoint->address->countryCode . "\n\n";
}

will output something like:

Min Købmand Nørre Uttrup
Nørre Uttrup Torv 15
9400 Nørresundby
DK

Shell 7-Eleven Nørresundby
Østergade 27-29
9400 Nørresundby
DK

Next-Data.Dk
Østerbrogade 79
9400 Nørresundby
DK

...

Production usage

Internally this library uses the CuyZ/Valinor library which is particularly well suited for turning API responses in DTOs. However, this library has some overhead and works best with a cache enabled.

When you instantiate the Client you can provide a MapperBuilder instance. Use this opportunity to set a cache:

<?php

use CuyZ\Valinor\Cache\FileSystemCache;
use CuyZ\Valinor\MapperBuilder;
use Setono\CoolRunner\Client\Client;
use Setono\CoolRunner\DTO\Collection;
use Setono\CoolRunner\DTO\Servicepoint;

require_once '../vendor/autoload.php';

$cache = new FileSystemCache('path/to/cache-directory');
$client = new Client('USERNAME', 'TOKEN', (new MapperBuilder())->withCache($cache));

You can read more about it here: Valinor: Performance and caching.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固