1. Go to this page and download the library: Download aboodma/aramex-integration 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/ */
aboodma / aramex-integration example snippets
use Aboodma\AramexIntegration\Config;
$config = (new Config())
->setUsername("your_username")
->setPassword("your_password")
->setVersion("v1.0")
->setAccountNumber("your_account_number")
->setAccountPin("your_account_pin")
->setAccountEntity("your_account_entity")
->setAccountCountryCode("your_account_country_code")
->setSource(24);
use Aboodma\AramexIntegration\Models\Address;
use Aboodma\AramexIntegration\Models\Contact;
use Aboodma\AramexIntegration\Models\Party;
use Aboodma\AramexIntegration\Models\Dimensions;
use Aboodma\AramexIntegration\Models\Weight;
use Aboodma\AramexIntegration\Models\Amount;
use Aboodma\AramexIntegration\Models\ShipmentDetails;
use Aboodma\AramexIntegration\Models\Shipment;
use Aboodma\AramexIntegration\Models\LabelInfo;
use Aboodma\AramexIntegration\Models\ClientInfo;
use Aboodma\AramexIntegration\AramexClient;
use Aboodma\AramexIntegration\Exceptions\AramexException;
// Shipper details
$shipperAddress = (new Address())
->setLine1("Test Shipper Address Line1")
->setLine2("Test Shipper Address Line2")
->setCity("Dubai")
->setPostCode("000000")
->setCountryCode("AE");
$shipperContact = (new Contact())
->setPersonName("Test Shipper Name")
->setCompanyName("Test Shipper Company Name")
->setPhoneNumber1("048707766")
->setCellPhone("971556893100")
->setEmailAddress("[email protected]");
$shipper = (new Party())
->setReference1("Shipper Reference")
->setAccountNumber("45796")
->setPartyAddress($shipperAddress)
->setContact($shipperContact);
// Consignee details
$consigneeAddress = (new Address())
->setLine1("Test Consignee Address Line1")
->setLine2("Test Consignee Address Line2")
->setLine3("Test Consignee Address Line3")
->setCity("Dubai")
->setStateOrProvinceCode("FU")
->setCountryCode("AE");
$consigneeContact = (new Contact())
->setPersonName("Test Consignee Name")
->setCompanyName("Test Consignee Company Name")
->setPhoneNumber1("048707766")
->setCellPhone("971556893100")
->setEmailAddress("[email protected]");
$consignee = (new Party())
->setAccountNumber("0")
->setPartyAddress($consigneeAddress)
->setContact($consigneeContact);
// Shipment details
$dimensions = (new Dimensions())
->setLength(0)
->setWidth(0)
->setHeight(0)
->setUnit("CM");
$actualWeight = (new Weight())
->setUnit("KG")
->setValue(0.1);
$chargeableWeight = (new Weight())
->setUnit("KG")
->setValue(0);
$amount = (new Amount())
->setCurrencyCode("AED")
->setValue(10);
$details = (new ShipmentDetails())
->setDimensions($dimensions)
->setActualWeight($actualWeight)
->setChargeableWeight($chargeableWeight)
->setDescriptionOfGoods("Items")
->setGoodsOriginCountry("AE")
->setNumberOfPieces(1)
->setProductGroup("DOM")
->setProductType("ONP")
->setPaymentType("P")
->setPaymentOptions("ACCT")
->setCustomsValueAmount($amount);
$shipment = (new Shipment())
->setShipper($shipper)
->setConsignee($consignee)
->setDetails($details)
->setReference1("Shipment Reference");
// Label info
$labelInfo = (new LabelInfo())
->setReportID(9729)
->setReportType("URL");
// Client info
$clientInfo = (new ClientInfo())
->setUserName("[email protected]")
->setPassword('R123456789$r')
->setVersion("v1.0")
->setAccountNumber("45796")
->setAccountPin("116216")
->setAccountEntity("DXB")
->setAccountCountryCode("AE")
->setSource(24);
// Initialize AramexClient and make the request
$client = new AramexClient($config);
try {
$response = $client->createShipment($shipment, $labelInfo, $clientInfo);
echo json_encode($response, JSON_PRETTY_PRINT);
} catch (AramexException $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
echo 'HTTP Status Code: ' . $e->getHttpStatusCode() . PHP_EOL;
echo 'Error Details: ' . print_r($e->getErrorDetails(), true);
}