1. Go to this page and download the library: Download tcgunel/omniship-horoz 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/ */
tcgunel / omniship-horoz example snippets
use Omniship\Omniship;
$carrier = Omniship::create('Horoz');
$carrier->initialize([
'processKey' => 'your-process-key',
'senderCode' => 12345,
'testMode' => true, // false for production
]);
use Omniship\Common\Address;
use Omniship\Common\Package;
use Omniship\Common\Enum\PaymentType;
// Step 1: Create the shipment
$response = $carrier->createShipment([
'shipFrom' => new Address(
name: 'Ahmet Yilmaz',
street1: 'Ataturk Cad. No:42',
city: 'Istanbul',
district: 'Kadikoy',
postalCode: '34710',
country: 'TR',
phone: '05551234567',
),
'shipTo' => new Address(
name: 'Mehmet Demir',
street1: 'Kizilirmak Cad. No:5',
city: 'Ankara',
district: 'Cankaya',
postalCode: '06420',
country: 'TR',
phone: '05559876543',
),
'packages' => [
new Package(weight: 2.5, length: 30, width: 20, height: 15),
],
'reference' => 'ORDER-001',
'paymentType' => PaymentType::SENDER,
])->send();
if ($response->isSuccessful()) {
$requestNumber = $response->getShipmentId(); // Horoz request number
// Step 2: Create barcode to get tracking number and label
$barcodeResponse = $carrier->createBarcode([
'requestNumber' => $requestNumber,
'partNumber' => 1,
'quantity' => 1,
'desi' => 3.0,
'weightInKg' => 2.5,
])->send();
if ($barcodeResponse->isSuccessful()) {
echo $barcodeResponse->getTrackingNumber(); // tracking number
echo $barcodeResponse->getBarcode(); // barcode string
$label = $barcodeResponse->getLabel(); // ZPL label
if ($label !== null) {
echo $label->format->value; // "ZPL"
}
}
}