mimicak / shipway-php-sdk
PHP client for Shipway API
Requires
- guzzlehttp/guzzle: ^7.10
- psr/http-client: ^1.0
- psr/http-factory: ^1.1
- psr/log: ^3.0
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- phpunit/phpunit: ^12.5
- vlucas/phpdotenv: ^5.3
This package is auto-updated.
Last update: 2026-03-04 14:48:19 UTC
README
A clean, structured PHP SDK for interacting with the Shipway API, providing support for order management, courier services, rate calculation, tracking, and manifests.
This SDK is designed as a Composer package, following PSR-4 autoloading and a clear separation of concerns (Config โ Client โ Resources โ Models).
๐ฆ Installation
Install via Composer:
composer require mimicak/shipway-php-sdk
Or include it manually by adding it to your composer.json.
๐ง Requirements
- PHP >= 7.4
- Composer
- cURL enabled
๐ง Architecture Overview
The SDK is structured into logical layers:
src/
โโโ Client # HTTP & response handling
โโโ Config # API configuration & endpoints
โโโ Exceptions # Domain-specific exceptions
โโโ Models
โ โโโ Request # Request DTOs
โ โโโ Response # Response DTOs
โ โโโ Core models (Order, Address, Product, etc.)
โโโ Resources # API feature modules
โโโ Shipway.php # SDK entry point
๐ Quick Start
1๏ธโฃ Create Configuration
use Shipway\Config\Configuration; $config = new Configuration([ 'api_key' => 'YOUR_API_KEY', 'base_url' => 'https://app.shipway.com/api' ]);
2๏ธโฃ Initialize SDK
use Shipway\Shipway; $shipway = new Shipway($config);
The Shipway class is the main entry point.
All API interactions go through resource accessors.
๐ฆ Resources & Usage
๐งพ Orders
$orders = $shipway->orders();
Supported operations:
- Create order
- Fetch order details
- Fetch order list
- Cancel shipment
- Generate manifest
Example:
use Shipway\Models\Request\ShipmentBooking\GetOrdersRequest; $request = new GetOrdersRequest([ 'from_date' => '2025-01-01', 'to_date' => '2025-01-31' ]); $response = $shipway->orders()->getOrders($request);
๐ Courier Services
$courier = $shipway->courier();
Supported operations:
- Get courier list
- Rate calculation
- Pincode serviceability
- Shipment tracking
Example โ Rate Calculation:
use Shipway\Models\Request\Carriers\GetCarrierRates; $request = new GetCarrierRates([ 'pickup_pincode' => '560001', 'delivery_pincode' => '110001', 'weight' => 1.5, 'cod' => true ]); $response = $shipway->courier()->getRates($request);
๐ญ Warehouse
$warehouse = $shipway->warehouse();
Handles warehouse-related Shipway APIs such as listing or configuration (based on API availability).
๐ Models
Core Models
OrderOrderListItemAddressProductShipmentStatusScan
Request Models
Located in:
src/Models/Request/
These classes encapsulate API request payloads and prevent passing raw arrays.
Response Models
Located in:
src/Models/Response/
These map API responses into typed PHP objects.
โ ๏ธ Exception Handling
All exceptions extend Shipway\Exceptions\ShipwayException.
Possible exceptions include:
AuthenticationExceptionValidationExceptionRateLimitExceptionNetworkExceptionConfigurationExceptionApiExceptionWebhookException
Example:
try { $shipway->orders()->getOrders($request); } catch (\Shipway\Exceptions\ShipwayException $e) { echo $e->getMessage(); }
๐ Configuration Errors
If the SDK is misconfigured (missing API key, invalid base URL), a ConfigurationException is thrown during initialization or request execution.
๐งช Examples
The examples/ directory is reserved for future usage samples and integration demos.
๐งฉ Extensibility
- All API modules extend
AbstractResource - HTTP logic is centralized in
HttpClient - Response parsing is handled by
ResponseHandler - Exception mapping is centralized in
ExceptionFactory
This makes the SDK easy to extend without breaking existing functionality.
๐ License
MIT License.
๐ค Contributing
Pull requests are welcome. Please ensure:
- PSR-12 compliance
- Typed models for requests/responses
- No breaking changes without version bumps
๐ฌ Support
For issues, feature requests, or API changes, open an issue on the repository.