inspirum/balikobot
Composer 安装命令:
composer require inspirum/balikobot
包简介
PHP library for Balikobot API
关键字:
README 文档
README
Offers implementation of Balikobot API v2 described in the official documentation until v2.0215 (2026-05-22).
More details are available in changelog.
Usage example
See more available methods' documentation in Usage section.
All the code snippets shown here are modified for clarity, so they may not be executable.
Create packages and order shipment
use Inspirum\Balikobot\Definitions\Carrier; use Inspirum\Balikobot\Definitions\Country; use Inspirum\Balikobot\Definitions\Currency; use Inspirum\Balikobot\Definitions\Service; use Inspirum\Balikobot\Model\PackageData\DefaultPackageData; use Inspirum\Balikobot\Model\PackageData\DefaultPackageDataCollection; use Inspirum\Balikobot\Service\PackageService; /** @var Inspirum\Balikobot\Service\PackageService $packageService */ // create new package collection for specific carrier $packagesData = new DefaultPackageDataCollection(Carrier::CP); // create new package $packageData = new DefaultPackageData(); $packageData->setServiceType(Service::CP_NP); $packageData->setRecName('Josef Novák'); $packageData->setRecZip('11000'); $packageData->setRecCountry(Country::CZECH_REPUBLIC); $packageData->setRecPhone('776555888'); $packageData->setCodPrice(1399.00); $packageData->setCodCurrency(Currency::CZK); // add package to collection $packagesData->add($packageData); // upload packages to balikobot $packages = $packageService->addPackages($packagesData); // save package IDs $data = []; $data['packages'] = $packages->getPackageIds(); // save track URL for each package foreach($packages as $package) { $data['trackUrl'][] = $package->getTrackUrl(); } // order shipment for packages $orderedShipment = $packageService->orderShipment($orderedPackages); // save order ID and labels URL $data['orderId'] = $orderedShipment->getOrderId(); $data['labelsUrl'] = $orderedShipment->getLabelsUrl(); $data['handoverUrl'] = $orderedShipment->getHandoverUrl(); /** var_dump($data); [ 'packages' => [ 0 => 42719 1 => 42720 ] 'trackUrl' => [ 0 => 'https://www.postaonline.cz/trackandtrace/-/zasilka/cislo?parcelNumbers=DR00112233M' 1 => 'https://www.postaonline.cz/trackandtrace/-/zasilka/cislo?parcelNumbers=DR00112234M' ] 'orderId' => 2757 'labelsUrl' => 'https://pdf.balikobot.cz/cp/eNorMTIwt9A1NbYwM76cMBAXAn4.' 'handoverUrl' => 'https://pdf.balikobot.cz/cp/eNorMTIwt9A1NbawtARcMBAhAoU.' ] */
Test packages data / delete packages
use Inspirum\Balikobot\Exception\Exception; /** @var Inspirum\Balikobot\Service\PackageService $packageService */ // check if packages data is valid try { $packageService->checkPackages($packagesData); } catch (Exception $exception) { return $exception->getErrors(); } // drop packages if shipment is not ordered yet $packageService->dropPackages($packages);
Track packages
use Inspirum\Balikobot\Definitions\Status; /** @var Inspirum\Balikobot\Service\TrackService $trackService */ // track last package status $status = $trackService->trackPackageLastStatus($packages[0]); /** var_dump($status); Inspirum\Balikobot\Model\Status\DefaultStatus { private $carrier => 'cp' private $carrierId => '1234' private $id => 2.2 private $name => 'Zásilka byla doručena příjemci.' private $description => 'Dodání zásilky. (77072 - Depo Olomouc 72)' private $type => 'event' private $date => DateTimeImmutable { '2018-07-02 09:15:01.000000' } } */ if (Status::isError($status->getId())) { // handle package delivery error } if ($status->getId() === Status::COD_PAID) { // CoD has been credited to the sender's account } if (Status::isDelivered($status->getId())) { // handle delivered package }
Import branches
use Inspirum\Balikobot\Definitions\Carrier; use Inspirum\Balikobot\Definitions\Country; /** @var Inspirum\Balikobot\Service\BranchService $branchService */ // get only branches for Zasilkovna in CZ/SK $branches = $branchService->getBranchesForCarrierAndCountries( Carrier::ZASILKOVNA, [Country::CZECH_REPUBLIC, Country::SLOVAKIA] ); foreach($branches as $branch) { /** var_dump($branch); Inspirum\Balikobot\Model\Branch\DefaultBranch { private $carrier => 'zasilkovna' private $service => null private $branchId => '10000' private $uid => 'VMCZ-zasilkovna-branch-10000' private $id => '10000' private $type => 'branch' private $name => 'Hradec Králové, Dukelská tř. 1713/7 (OC Atrium - Traficon) Tabák Traficon' private $city => 'Hradec Králové' private $street => 'Dukelská tř. 1713/7' private $zip => '50002' private $cityPart => null private $district => 'okres Hradec Králové' private $region => 'Královéhradecký kraj' private $country => 'CZ' ... } */ }
System requirements
If you are still using older PHP version, you can use this package in ^5.0 version (for PHP 7.1+).
Installation
Run composer require command:
composer require inspirum/balikobot
or add a requirement to your composer.json:
"inspirum/balikobot": "^7.0"
Setup service
Available framework integrations:
But you can also use it without any framework implementation:
use Inspirum\Balikobot\Client\DefaultClient; use Inspirum\Balikobot\Client\DefaultCurlRequester; use Inspirum\Balikobot\Client\Response\Validator; use Inspirum\Balikobot\Model\Label\DefaultLabelFactory; use Inspirum\Balikobot\Model\OrderedShipment\DefaultOrderedShipmentFactory; use Inspirum\Balikobot\Model\Package\DefaultPackageFactory; use Inspirum\Balikobot\Model\PackageData\DefaultPackageDataFactory; use Inspirum\Balikobot\Model\ProofOfDelivery\DefaultProofOfDeliveryFactory; use Inspirum\Balikobot\Model\Status\DefaultStatusFactory; use Inspirum\Balikobot\Model\TransportCost\DefaultTransportCostFactory; use Inspirum\Balikobot\Service\DefaultPackageService; use Inspirum\Balikobot\Service\DefaultTrackService; $apiUser = getenv('BALIKOBOT_API_USER'); $apiKey = getenv('BALIKOBOT_API_KEY'); $requester = new DefaultCurlRequester($apiUser, $apiKey, sslVerify: true); $validator = new Validator(); $client = new DefaultClient($requester, $validator); $packageService = new DefaultPackageService( $client, new DefaultPackageDataFactory(), new DefaultPackageFactory($validator), new DefaultOrderedShipmentFactory(), new DefaultLabelFactory(), new DefaultProofOfDeliveryFactory($validator), new DefaultTransportCostFactory($validator), ); $trackService = new DefaultTrackService( $client, new DefaultStatusFactory($validator), ); // ...
Usage
The module contains several helper classes that contain most of the constants needed to work with the Balikobot API.
Testing
To run unit tests, run:
composer test:test
You can also run only Unit or Integration test suites, run:
composer test:unit
composer test:integration
To show coverage, run:
composer test:coverage
To run all test (phpcs, phpstan, phpunit, etc.), run:
composer test
For testing purposes, you can use these credentials:
- API username:
balikobot_test2cztest - API key:
#lS1tBVo
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email tomas.novotny@inspirum.cz instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
inspirum/balikobot 适用场景与选型建议
inspirum/balikobot 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 400.64k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2019 年 01 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「API-Client」 「Balikobot」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 inspirum/balikobot 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 inspirum/balikobot 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 inspirum/balikobot 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony bundle for inspirum/balikobot library
Skolkovo API Client
Balikobot API
A client library for the OpenPLZ API project
chargebee-php-sdk integration for WordPress
统计信息
- 总下载量: 400.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 7
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-02