定制 captain-courier/cidr 二次开发

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

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

captain-courier/cidr

Composer 安装命令:

composer require captain-courier/cidr

包简介

Courier Integration Done Right!

README 文档

README

Cidr's goals are simpe, make working with couriers easy.

Cidr will be able to:

  • provide the cheapest quotes from couriers
  • create/view/delete/track shipment requests with minimum customization for a particular courier
  • get shipping labels

Current features:

  • create shipments with couriers ParcelForce and P4D

install

Cidr source can be downloaded from github, or can be added as a dependency through Composer by adding the following your composer.json:

{
    ....
    "require": {
        ....
        "captain-courier/cidr": "*"
    }

}

setup

create a file res/credentials.yml in the project directory. It will look something like this:

ParcelForce:
    username: <insert here>
    password: <insert here>
P4D:
    username: <insert here>
    apiKey: <insert here>

Where you would replace <insert here> with your username/password/apiKey. If you don't need one of the couriers, don't add it to the credentials.yml file. For example if you only needed ParcelForce then the credentials.yml file would look like:

ParcelForce:
    username: <insert here>
    password: <insert here>

Whilsts testing Cidr it is recommended to use test credentials instead of production credentials. P4D provide test credentials without signing up, just goto http://www.p4d.co.uk/v2/api.

testing

Cidr uses Travis for testing, available here. Cidr can be tested locally by running:

phpunit --configuration=phpunit.xml src/

usage

An example below for creating a shipment with ParcelForce:

use Cidr\Cidr;
use Cidr\CidrRequest;
use Cidr\CidrResponse;


// creates a new Cidr object
// the cidr object provides capabilities, which are objects that can only 
// perform 1 task for 1 courier such as creating a consignment for ParcelForce.
$cidr = new Cidr();
$capability = $cidr->getCapability("ParcelForce", "CreateConsignment");
$request = new CidrRequest(...);

// submits the request to the courier[s] and returns a Cidr\CidrResponse object.
// response has a context properties which is different depending on the status of the response.
$response = $capability->submitCidrRequest($request);

// checks the request was successful, and prints out the assigned consignment number.
// if the request failed, it prints out the response context to get an idea why it has failed.
if (CidrResponse::STATUS_SUCCESS === $response->getStatus()) {
    // gets the consignment number assigned for the created shipment
    $consignmentNumber = $response->getResponseContext();
    print "consignment number is '${consignmentNumber}'\n";
    exit(0);
} else {
  print "request failed\n";
  print_r($response->getResponseContext());
  exit(1);
}



统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: AGPL-3.0
  • 更新时间: 2013-09-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固