PHP code example of farmto / shippo-laravel
1. Go to this page and download the library: Download farmto/shippo-laravel 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/ */
farmto / shippo-laravel example snippets
use FarmToYou\ShippoLaravel\Facades\ShippoCarrier;
// Create a shipping label
$shipment = ShippoCarrier::createShipment([
'address_from' => [
'name' => 'John Doe',
'street1' => '123 Main St',
'city' => 'San Francisco',
'state' => 'CA',
'zip' => '94105',
'country' => 'US',
],
'address_to' => [
'name' => 'Jane Doe',
'street1' => '456 Oak St',
'city' => 'New York',
'state' => 'NY',
'zip' => '10001',
'country' => 'US',
],
'parcels' => [
[
'length' => 10,
'width' => 8,
'height' => 4,
'distance_unit' => 'in',
'weight' => 2,
'mass_unit' => 'lb',
],
],
]);
// Get available shipping rates
$rates = ShippoCarrier::getShipmentRates($shipment['object_id']);
// Purchase a label
$transaction = ShippoCarrier::purchaseShippingLabel($rates[0]['object_id']);
bash
php artisan vendor:publish --provider="FarmToYou\ShippoLaravel\ShippoCarrierServiceProvider"
SHIPPO_API_KEY=your_api_key_here
SHIPPO_API_VERSION=2018-02-08
bash
composer dump-autoload