1. Go to this page and download the library: Download shibin/aramex-laravel 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/ */
use Shibin\Aramex\Facades\Aramex;
// Get all countries
$countries = Aramex::location()->countries();
// Get cities within a country
$cities = Aramex::location()->cities('SA'); // Saudi Arabia
use Shibin\Aramex\Facades\Aramex;
use Shibin\Aramex\DTO\Address;
use Shibin\Aramex\DTO\RateRequest;
// 1. Define Origin & Destination
$origin = new Address(line1: 'Street', city: 'Amman', country_code: 'JO');
$destination = new Address(line1: 'Street', city: 'Jeddah', country_code: 'SA');
// 2. Create Request
$request = new RateRequest(
origin: $origin,
destination: $destination,
weight: 5.0,
pieces: 1,
currency: 'USD'
);
// 3. Calculate
$response = Aramex::rates()->calculate($request);
use Shibin\Aramex\Facades\Aramex;
use Shibin\Aramex\DTO\Address;
use Shibin\Aramex\DTO\Shipment;
$shipper = new Address(
line1: 'Gardens St', city: 'Amman', country_code: 'JO',
name: 'Shipper Name', email: '[email protected]', phone: '0790000000'
);
$consignee = new Address(
line1: 'Fahad Rd', city: 'Riyadh', country_code: 'SA',
name: 'Receiver Name', email: '[email protected]', phone: '0500000000'
);
$shipment = new Shipment(
shipper: $shipper,
consignee: $consignee,
shipping_date_time: time() + 3600,
due_date: time() + 86400,
comments: 'Handle with care',
pickup_location: 'Reception',
weight: 2.5,
number_of_pieces: 1,
description: 'Electronics',
payment_type: 'P'
);
$response = Aramex::shipments()->create($shipment);
// Access the Waybill Number
$waybill = $response->Shipments->ProcessedShipment->ID ?? null;
$shipmentNumber = "37133804481"; // The ID from the create shipment response
$response = Aramex::shipments()->printLabel($shipmentNumber);
if (isset($response->ShipmentLabel->LabelFileContents)) {
$pdfContent = $response->ShipmentLabel->LabelFileContents;
// Save to storage
Storage::disk('public')->put("label_{$shipmentNumber}.pdf", $pdfContent);
}