定制 faiznurullah/rajaongkir 二次开发

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

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

faiznurullah/rajaongkir

Composer 安装命令:

composer require faiznurullah/rajaongkir

包简介

package for php application for connect with rajaongkir service

README 文档

README

A lightweight PHP library to access RajaOngkir endpoints through https://rajaongkir.komerce.id/api/v1.

Features

  • Get provinces
  • Get cities by province
  • Get districts by city
  • Get subdistricts by district
  • Calculate domestic shipping cost by district
  • Track waybill (AWB)
  • Search domestic destinations

Requirements

  • PHP 7.4+
  • Composer

Installation

If you are using this package in another project:

composer require faiznurullah/rajaongkir

For local development in this repository:

composer install

Quick Start

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Faiznurullah\Rajaongkir\RajaOngkir;

$apiKey = 'YOUR_API_KEY';
$rajaOngkir = new RajaOngkir($apiKey);

$provinces = $rajaOngkir->getProvinces();
print_r($provinces);

API Methods

1) Get Provinces

$response = $rajaOngkir->getProvinces();

2) Get Cities

$provinceId = 5;
$response = $rajaOngkir->getCities($provinceId);

3) Get Districts

$cityId = 39;
$response = $rajaOngkir->getDistrict($cityId);

4) Get Subdistricts

$districtId = 574;
$response = $rajaOngkir->getSubdistrict($districtId);

5) Calculate District Shipping Cost

$originDistrictId = 574;
$destinationDistrictId = 114;
$weight = 1000; // grams
$courier = 'jne';

$response = $rajaOngkir->calculateDistrictCost(
	$originDistrictId,
	$destinationDistrictId,
	$weight,
	$courier
);

6) Track Waybill

$waybill = 'JP1234567890';
$courier = 'jne';

$response = $rajaOngkir->trackWaybill($waybill, $courier);

7) Search Domestic Destination

$query = 'Bandung';

// With optional limit and offset
$response = $rajaOngkir->searchDomesticDestination($query, 10, 0);

// Without optional arguments
$response = $rajaOngkir->searchDomesticDestination($query);

Error Handling

All methods return an array.

If a request fails, the library returns an array with an error description (from Guzzle exception or generic exception), for example:

[
	'rajaongkir' => [
		'status' => [
			'code' => 500,
			'description' => 'Error: ...'
		]
	]
]

Run Local Test Script

This repository includes src/test.php.

From project root:

php src/test.php

Or from src directory:

php test.php

Troubleshooting

Class not found (RajaOngkir)

Make sure Composer autoload is loaded before using the class:

require_once __DIR__ . '/../vendor/autoload.php';

Warning: Module "ftp" is already loaded

This warning comes from your PHP extension configuration and is unrelated to this package.

Check your php.ini and remove duplicate extension=ftp entries.

License

MIT

faiznurullah/rajaongkir 适用场景与选型建议

faiznurullah/rajaongkir 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 faiznurullah/rajaongkir 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 faiznurullah/rajaongkir 我们能提供哪些服务?
定制开发 / 二次开发

基于 faiznurullah/rajaongkir 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-07