定制 farmto/shippo-laravel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

farmto/shippo-laravel

最新稳定版本:v1.18.10

Composer 安装命令:

composer require farmto/shippo-laravel

包简介

Laravel integration for Shippo Api

README 文档

README

A Laravel package that integrates the Shippo API into your Laravel application for easy shipping label generation, tracking, and carrier management.

Latest Version on Packagist Total Downloads

Installation

You can install the package via composer:

composer require FarmToYou/shippo-laravel

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="FarmToYou\ShippoLaravel\ShippoCarrierServiceProvider"

Then update your .env file with your Shippo API credentials:

SHIPPO_API_KEY=your_api_key_here
SHIPPO_API_VERSION=2018-02-08

Usage

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']);

Troubleshooting

If you encounter the error "Class 'FarmToYou\ShippoLaravels\ShippoCarriersServiceProvider' not found", there might be a namespace discrepancy. Make sure your service provider uses the correct namespace as defined in your composer.json file.

For service provider issues:

Check that your composer.json has the correct PSR-4 autoloading configuration:

"autoload": {
    "psr-4": {
        "FarmToYou\\ShippoLaravel\\": "src/"
    }
}

Then run:

composer dump-autoload

License

The MIT License (MIT). Please see License File for more information.

Credits

统计信息

  • 总下载量: 104
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-21