定制 shipbg/php-sdk 二次开发

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

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

shipbg/php-sdk

Composer 安装命令:

composer require shipbg/php-sdk

包简介

Portable, dependency-free PHP SDK for the ShipBG multi-carrier shipping API (generated from the OpenAPI spec).

README 文档

README

Portable, dependency-free PHP client for the ShipBG multi-carrier shipping API. Generated from the OpenAPI spec — typed request methods + DTOs, single source of truth, no drift.

  • PHP 7.4+, zero Composer dependencies (just ext-curl + ext-json).
  • Pluggable transport — ships a CurlTransport default; inject any Transport (e.g. a WordPress wp_remote_* adapter, Guzzle, Symfony HttpClient). Same SDK on WooCommerce, Magento, OpenCart, plain PHP.
  • Resource-grouped, fully typed: $client->rates->quote($payload) returns a QuoteRatesResult.

Install

composer require shipbg/php-sdk

Usage

use ShipBG\Sdk\Client;

$client = new Client('YOUR_API_TOKEN');                 // default CurlTransport
// or inject a platform transport:
// $client = new Client($token, 'https://shipbg.com/api/v1', new MyWpRemoteTransport());

$account = $client->account->show();                    // GET  /account    → AccountResponseData
$rates   = $client->rates->quote([                      // POST /rates:quote → QuoteRatesResult
    'from_address' => [/* ... */],
    'to_address'   => [/* ... */],
    'parcel'       => ['weight' => 1.5],
    'currency'     => 'BGN',
]);

foreach ($rates->rates as $rate) {
    // typed DTO graph
}

Errors raise ShipBG\Sdk\Exception\ApiException (getStatus(), getType(), getBody()).

Custom transport

Implement ShipBG\Sdk\Transport to route HTTP through your platform's stack:

final class WpRemoteTransport implements \ShipBG\Sdk\Transport
{
    public function send(string $method, string $url, array $headers, ?string $body): array
    {
        $res = wp_remote_request($url, ['method' => $method, 'headers' => $headers, 'body' => $body]);
        return [(int) wp_remote_retrieve_response_code($res), (string) wp_remote_retrieve_body($res)];
    }
}

Regenerating

Generated from backend/docs/api/openapi.snapshot.json by tools/sdk-generator/generate-plain.php in the monorepo. Regenerate, commit, git tag vX.Y.Z && git push --tags → Packagist auto-updates.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固