Skip to content

Installation

Igor Sazonov edited this page Mar 5, 2026 · 1 revision

This guide will walk you through the process of installing the Shippo PHP SDK in your project.

Prerequisites

Before you begin, ensure you have the following prerequisites installed:

Step 1: Install via Composer

To install the package, run the following command in your project's root directory:

composer require tigusigalpa/shippo-php

Step 2: Get Your API Token

To use the Shippo API, you need an API token. You can find your token in your Shippo dashboard:

  1. Log in to your Shippo Dashboard.
  2. Navigate to Settings → API.
  3. Copy your Test Token for development and your Live Token for production.

Standalone PHP Usage

For projects without a framework, you'll need to include the Composer autoloader and manually instantiate the Shippo client.

<?php

require 'vendor/autoload.php';

use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\HttpFactory;
use Tigusigalpa\Shippo\Config;
use Tigusigalpa\Shippo\Shippo;

// Create configuration
$config = Config::make('your_test_token_here', [
    'is_test' => true,
]);

// Initialize HTTP dependencies
$httpFactory = new HttpFactory();

// Create Shippo client
$shippo = new Shippo(
    httpClient: new GuzzleClient(),
    requestFactory: $httpFactory,
    streamFactory: $httpFactory,
    config: $config
);

// Use the client
$address = $shippo->addresses()->create([
    'name' => 'John Doe',
    'street1' => '215 Clayton St.',
    'city' => 'San Francisco',
    'state' => 'CA',
    'zip' => '94117',
    'country' => 'US',
]);

echo "Address created: {$address->objectId}\n";

Laravel Integration

If you are using Laravel, the package will automatically register its service provider. You can publish the configuration file to customize the settings.

  1. Publish the configuration file:

    php artisan vendor:publish --tag=shippo-config
  2. Add your API token to your .env file:

    SHIPPO_API_TOKEN=your_shippo_api_token_here
    SHIPPO_IS_TEST=true

With this setup, you can now use the Shippo facade in your Laravel application.

Clone this wiki locally