PHP code example of vasildakov / shipping

1. Go to this page and download the library: Download vasildakov/shipping 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/ */

    

vasildakov / shipping example snippets

 


$econt  = Shipping::create('Econt');

$request = new GetCountriesRequest(name: 'Bul');

/** @var GetCountriesResponse $response */
$response = $econt->getCountries();




use VasilDakov\Shipping\Shipping;
use VasilDakov\Shipping\Adapter\EcontAdapter;
use VasilDakov\Shipping\Adapter\SpeedyAdapter;

// using strings
$econt  = Shipping::create('Econt');
$speedy = Shipping::create('Speedy');


// ... or using class name
$econt  = Shipping::create(EcontAdapter::class);
$speedy = Shipping::create(SpeedyAdapter::class);
 


$econt  = Shipping::create('Econt');

$request = new GetCountriesRequest(name: 'Bul');

/** @var GetCountriesResponse $response */
$response = $econt->getCountries();

foreach ($response->countries as $country) {
    dump($country);
}
 

$econt  = Shipping::create('Econt');

$request = new GetCitiesRequest(isoAlpha3: 'BGR', name: null);

/** @var GetCitiesResponse $response */
$response = $econt->getCities($request);

foreach ($response->cities as $city) {
    dump($city);
}

 

$econt  = Shipping::create('Econt');

$request = new GetOfficesRequest(isoAlpha3: 'BGR', name: null);

/** @var GetCitiesResponse $response */
$response = $econt->getOffices($request);

foreach ($response->offices as $office) {
    dump($office);
}