PHP code example of bluefyn-international / shipengine

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

    

bluefyn-international / shipengine example snippets


return [
    /*
    |--------------------------------------------------------------------------
    | ShipEngine configurations
    |--------------------------------------------------------------------------
    |
    | API Key used to authenticate with ShipEngine APIs.
    | https://www.shipengine.com/docs/auth/
    |
    */
    'credentials' => [
        'key' => env('SHIP_ENGINE_API_KEY'),
    ],

    /*
    |--------------------------------------------------------------------------
    | ShipEngine configurations
    |--------------------------------------------------------------------------
    |
    | Values used to set configuration of ShipEngine API integration.
    |
    */
    'endpoint' => [
        'version'  => env('SHIP_ENGINE_API_VERSION', 'v1'),
        'base'     => env('SHIP_ENGINE_ENDPOINT', 'https://api.shipengine.com/'),
    ],
    'retries'  => env('SHIP_ENGINE_RETRIES', 1),
    'response' => [
        'as_object' => env('SHIP_ENGINE_RESPONSE_AS_OBJECT', false),
        'page_size' => env('SHIP_ENGINE_RESPONSE_PAGE_SIZE', 50),
    ],
    'timeout' => 'PT10S',
];

// Use default config settings from `config/shipengine.php`
$shipengine = new AlwaysOpen\ShipEngine\ShipEngine();
// Override config which will impact all calls made with this instance
$config = new \AlwaysOpen\ShipEngine\ShipEngineConfig(['asObject' => true]);
$custom_shipengine = new AlwaysOpen\ShipEngine\ShipEngine($config);
// Override config on a single specific call
$shipengine->listShipments(config: ['asObject' => true]);

$shipengine = new AlwaysOpen\ShipEngine\ShipEngine();
$shipengine->listShipments();
//[
//    "shipments" => [
//        [
//            "shipment_id" => "se-123456789",
//            "carrier_id" => "se-123456",
//            ...
//        ],
//        [...],
//    ],
//    "total" => 12,
//    "page" => 1,
//    "pages" => 1,
//    "links" => [
//        "first" => [
//             "href" => "https://api.shipengine.com/v1/shipments?page=1&page_size=25",
//        ],
//        "last" => [
//             "href" => "https://api.shipengine.com/v1/shipments?page=1&page_size=25",
//        ],
//        "prev" => [],
//        "next" => [],
//     ],
//];
$shipengine->listShipments(config: ['asObject' => true]);
// [
//     "shipments" => [
//       AlwaysOpen\ShipEngine\DTO\Shipment {#4070
//           +shipment_id: "se-123456789",
//           +carrier_id: "se-123456",
//            ...
//        ],
//        [...],
//    ],
//    "total" => 12,
//    "page" => 1,
//    "pages" => 1,
//    "links" => [
//        "first" => [
//             "href" => "https://api.shipengine.com/v1/shipments?page=1&page_size=25",
//        ],
//        "last" => [
//             "href" => "https://api.shipengine.com/v1/shipments?page=1&page_size=25",
//        ],
//        "prev" => [],
//        "next" => [],
//     ],
//];
bash
php artisan vendor:publish --tag="shipengine-config"