vasildakov/shipping 问题修复 & 功能扩展

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

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

vasildakov/shipping

最新稳定版本:v0.1.0-alpha

Composer 安装命令:

composer require vasildakov/shipping

包简介

Shipping Library

README 文档

README

build Scrutinizer Code Quality Code Coverage Total Downloads

Features

This library is compliant with PSR-7: HTTP message interfaces, PSR-17: HTTP Factories and PSR-18: HTTP Client

Installation

Using Composer:

$ composer require vasildakov/shipping

Tests

$ ./vendor/bin/phpunit 

# with code coverage
$ ./vendor/bin/phpunit --coverage-html ./build/coverage

Configuration

...

Add your adapters configuration to a .env file in the root of your project. Make sure the .env file is added to your .gitignore so it is not checked-in the code

SPEEDY_USERNAME="username"
SPEEDY_PASSWORD="password"
SPEEDY_LANGUAGE="EN"

ECONT_USERNAME="username"
ECONT_PASSWORD="password"

Usage

Here is a simple example of how to use Shipping. As you can see, Shipping has a consistent, well thought out API. As much as possible, we try to abstract the differences between the various shipping gateways.

<?php

$econt  = Shipping::create('Econt');

$request = new GetCountriesRequest(name: 'Bul');

/** @var GetCountriesResponse $response */
$response = $econt->getCountries();
<?php

use VasilDakov\Shipping\Shipping;
use VasilDakov\Shipping\Adapter\EcontAdapter;
use VasilDakov\Shipping\Adapter\SpeedyAdapter;

// using strings
$econt  = Shipping::create('Econt');
$speedy = Shipping::create('Speedy');


// ... or using class name
$econt  = Shipping::create(EcontAdapter::class);
$speedy = Shipping::create(SpeedyAdapter::class);

Services

1 Countries

<?php

$econt  = Shipping::create('Econt');

$request = new GetCountriesRequest(name: 'Bul');

/** @var GetCountriesResponse $response */
$response = $econt->getCountries();

foreach ($response->countries as $country) {
    dump($country);
}

2 Cities

<?php
$econt  = Shipping::create('Econt');

$request = new GetCitiesRequest(isoAlpha3: 'BGR', name: null);

/** @var GetCitiesResponse $response */
$response = $econt->getCities($request);

foreach ($response->cities as $city) {
    dump($city);
}

3 Offices

<?php
$econt  = Shipping::create('Econt');

$request = new GetOfficesRequest(isoAlpha3: 'BGR', name: null);

/** @var GetCitiesResponse $response */
$response = $econt->getOffices($request);

foreach ($response->offices as $office) {
    dump($office);
}

License

Code released under the MIT license

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-29