1. Go to this page and download the library: Download ages/shipping-gateway 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/ */
ages / shipping-gateway example snippets
use Ages\ShippingGateway\Common\Carrier;
use Ages\ShippingGateway\Common\Shipment\CashOnDelivery;
use Ages\ShippingGateway\Common\Shipment\Parcel;
use Ages\ShippingGateway\Common\Shipment\RecipientAddress;
use Ages\ShippingGateway\Common\Shipment\ShipmentRequest;
use Ages\ShippingGateway\Common\Shipment\ShipmentValue;
$request = new ShipmentRequest(
reference: '2025-00123',
recipient: RecipientAddress::fromFullName(
name: 'Jan Novák',
street: 'Hlavní',
houseNumber: '42',
city: 'Praha',
zip: '10000',
country: 'CZ',
phone: '+420600123456',
email: '[email protected]',
),
parcels: [
new Parcel(weight: 2.5),
new Parcel(weight: 1.8),
],
value: new ShipmentValue(amount: 1490.0),
cod: new CashOnDelivery(amount: 1490.0, variableSymbol: '2025001'),
note: 'Poznámka pro přepravu',
// Pro výdejní místa:
// parcelShopCode: 'B69623',
// parcelShopZip: '69623', // u České pošty explicitně PSČ provozovny
);
/** @var \Ages\ShippingGateway\ShippingGateway $gateway */
$labels = $gateway->createShipment(Carrier::Gls, $request);
foreach ($labels as $label) {
echo $label->trackingNumber; // číslo zásilky
file_put_contents('label.pdf', $label->labelPdf); // raw PDF bytes
}
// Ze jména — rozdělí podle první mezery (Jan / Novák)
RecipientAddress::fromFullName('Jan Novák', $street, $city, $zip, $country, $phone, $email);
// Nebo přímo s firstName / lastName
new RecipientAddress(
firstName: 'Jan',
lastName: 'Novák',
street: 'Hlavní',
city: 'Praha',
zip: '10000',
country: 'CZ',
phone: '+420600123456',
email: '[email protected]',
company: 'Firma s.r.o.', // volitelné
houseNumber: '42', // volitelné
type: RecipientType::Company, // Person (výchozí) nebo Company
);
use Ages\ShippingGateway\Common\Shipment\Dimensions;
use Ages\ShippingGateway\Common\Shipment\ParcelType;
new Parcel(weight: 2.5); // standardní balík
new Parcel(weight: 15.0, type: ParcelType::PackageOversize); // neskladný / atypický
new Parcel(weight: 80.0, type: ParcelType::PalletEur); // EUR paleta (GebrüderWeiss)
new Parcel(weight: 60.0, type: ParcelType::PalletOneWay); // jednorázová paleta
new Parcel(weight: 50.0, type: ParcelType::PalletHalf); // půl paleta
new Parcel(weight: 40.0, type: ParcelType::PalletCustom); // vlastní paleta
// S rozměry — hodnoty v cm; u Gebrüder Weiss se odesílají jako metry (automatická konverze ÷ 100)
new Parcel(weight: 5.0, dimensions: new Dimensions(60, 40, 30));
$label->carrier; // Carrier::Gls | Carrier::Ppl | Carrier::CzechPost
$label->trackingNumber; // číslo zásilky pro sledování
$label->labelPdf; // raw PDF bytes — ulož nebo pošli do prohlížeče
// Uložení štítku
file_put_contents('/path/to/' . $label->trackingNumber . '.pdf', $label->labelPdf);
// Sledování zásilky (po doručení)
$tracking = $gateway->tracking($label->carrier, $label->trackingNumber);