PHP code example of shipkit-bd / laravel-courier-bd
1. Go to this page and download the library: Download shipkit-bd/laravel-courier-bd library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shipkit-bd / laravel-courier-bd example snippets
use Shipkit\CourierBD\Facades\Courier;
use Shipkit\CourierBD\DTOs\OrderRequest;
$order = new OrderRequest(
merchantOrderId: 'INV-2026-001',
recipientName: 'Abul Hossain',
recipientPhone: '01711223344',
recipientAddress: 'House 12, Road 5, Dhanmondi, Dhaka',
recipientCity: 'Dhaka',
amountToCollect: 1500.00, // COD Amount
itemWeight: 1.0, // kg
itemDescription: 'Cotton Polo Shirt x 2',
specialInstruction: 'Handle with care'
);
// Create shipment with default driver
$response = Courier::createOrder($order);
echo $response->consignmentId; // e.g. ST100200
echo $response->status->label(); // Pending
echo $response->trackingUrl; // https://steadfast.com.bd/t/ST100200
// Use Pathao
$pathaoResponse = Courier::via('pathao')->createOrder($order);
// Use RedX
$redxResponse = Courier::via('redx')->createOrder($order);
$tracking = Courier::via('pathao')->track('PTH123456');
if ($tracking->status->isFinal()) {
echo "Delivery Completed or Cancelled: " . $tracking->status->label();
}
use Shipkit\CourierBD\Events\ShipmentStatusUpdated;
use Shipkit\CourierBD\Events\ShipmentDelivered;
Event::listen(ShipmentStatusUpdated::class, function (ShipmentStatusUpdated $event) {
logger("Consignment {$event->consignmentId} status changed to {$event->newStatus->label()}");
});
Event::listen(ShipmentDelivered::class, function (ShipmentDelivered $event) {
// Mark order as completed in your app
});
bash
php artisan shipkit:install
bash
php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.