sudiptpa/transdirect
Composer 安装命令:
composer require sudiptpa/transdirect
包简介
A clean, dependency-free PHP client for the Transdirect REST API.
README 文档
README
A clean, dependency-free PHP client for the Transdirect REST API.
- PHP 7.0+
- no runtime HTTP dependency
- fluent resource API
- configurable live and sandbox endpoints
- transport injection for tests
Install
composer require sudiptpa/transdirect
Quick start
use Sujip\Transdirect\Transdirect; $client = Transdirect::connect($apiKey); $response = $client->quotes()->create([ 'declared_value' => '1000.00', 'referrer' => 'API', 'requesting_site' => 'https://example.com.au', 'items' => [ [ 'weight' => '38.63', 'height' => '0.25', 'width' => '1.65', 'length' => '3.32', 'quantity' => 1, 'description' => 'carton', ], ], 'sender' => [ 'address' => '21 Kirksway Place', 'company_name' => 'Sender Company', 'email' => 'sender@example.com', 'name' => 'Sender Name', 'postcode' => '2000', 'phone' => '0212345678', 'state' => 'NSW', 'suburb' => 'SYDNEY', 'type' => 'business', 'country' => 'AU', ], 'receiver' => [ 'address' => '216 Moggill Rd', 'company_name' => 'Receiver Company', 'email' => 'receiver@example.com', 'name' => 'Receiver Name', 'postcode' => '3000', 'phone' => '0312345678', 'state' => 'VIC', 'suburb' => 'MELBOURNE', 'type' => 'business', 'country' => 'AU', ], ]); $quotes = $response->getQuotes();
Resources
$client->quotes()->create($payload); $client->bookings()->create($payload); $client->bookings()->find($bookingId); $client->bookings()->update($bookingId, $payload); $client->bookings()->delete($bookingId); $client->bookings()->action($bookingId, 'confirm', $payload); $client->bookings()->nested($bookingId, 'label'); $client->orders()->create($payload); $client->locations()->get(['q' => 'Sydney']); $client->couriers()->get(); $client->member()->get(); $client->frequentRates()->get();
Helpers
$client->tracking($bookingId); $client->postcode('3000'); $client->pagedLocations(2);
Sandbox
$client = Transdirect::connect($apiKey) ->setSandboxEndpoint('https://sandbox.example.test/api') ->useSandbox();
Sandbox mode now requires an explicit sandbox endpoint.
Custom transport
$client = new Transdirect($apiKey, function ($method, $url, $headers, $body) { return [ 'status' => 200, 'headers' => ['Content-Type' => 'application/json'], 'body' => '{"ok":true}', ]; });
Testing
composer test composer stan find src tests -name '*.php' -print0 | xargs -0 -n1 php -l
Docs
sudiptpa/transdirect 适用场景与选型建议
sudiptpa/transdirect 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 112 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「shipping」 「courier」 「transdirect」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sudiptpa/transdirect 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sudiptpa/transdirect 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sudiptpa/transdirect 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
统计信息
- 总下载量: 112
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-04-30