PHPackages                             bedard/shipping - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. bedard/shipping

ActiveLibrary[API Development](/categories/api)

bedard/shipping
===============

API wrapper for shipping calculations.

21101PHP

Since Jan 9Pushed 11y ago1 watchersCompare

[ Source](https://github.com/scottbedard/shipping)[ Packagist](https://packagist.org/packages/bedard/shipping)[ RSS](/packages/bedard-shipping/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

USPS Shipping Calculator
========================

[](#usps-shipping-calculator)

[![Build Status](https://camo.githubusercontent.com/b7cd63f80df9f2afcbd79e1c54b540bca83c1bb04f7187b0f397d04a1aac70bd/68747470733a2f2f7472617669732d63692e6f72672f73636f74746265646172642f7368697070696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/scottbedard/shipping)[![Coverage Status](https://camo.githubusercontent.com/66a888fe053e022a3f6d2ebc6dc09d379cfedc5a00ead29951dbdb678dc7632f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f73636f74746265646172642f7368697070696e672f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/scottbedard/shipping?branch=master)

A simple PHP wrapper for USPS shipping calulations.

### Instructions

[](#instructions)

The first step to requesting a shipping quote is injecting your USPS Web Tools ID.

```
use Bedard\Shipping\Usps;
$shipment = new Usps('123ABCDE4567');
```

If you would like to run the calculator on the USPS testing server, call `useTestingServer()`.

```
$shipment->useTestingServer();
```

Once this is done, it's time to build up the data you'll be sending to USPS. Length, width, and height are all specified in inches. Pounds, ounces, and setValue() are all optional.

```
$rates = $shipment
    ->setOrigin('12345')
    ->setDestination('90210')
    ->setDimensions([
        'length'    => 12,
        'width'     => 12,
        'height'    => 4,
        'pounds'    => 0,
        'ounces'    => 1
    ])
    ->setValue(49.99)
    ->calculate();
```

The above is an example of a domestic shipment. To request an international rate, simply pass the destination country into `setDestination()` instead of a postal code.

```
$shipment->setDestination('Canada');
```

Once you've called `calculate()`, shipping rates will be returned in the following format. Results will be ordered by cost in ascending order.

```
 1 =>
    array (size=3)
      'code' => string '01' (length=2)
      'name' => string 'First-Class Mail Large Envelope' (length=31)
      'cost' => float 0.98
  2 =>
    array (size=3)
      'code' => string '00' (length=2)
      'name' => string 'First-Class Mail Parcel' (length=23)
      'cost' => float 2.32
  3 =>
    array (size=3)
      'code' => string '1' (length=1)
      'name' => string 'Priority Mail 2-Day' (length=19)
      'cost' => float 5.75

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/904cc72c102eb3725fdc5191aaf7519724839af6feb847dc20dfa138f37e50b2?d=identicon)[scottbedard](/maintainers/scottbedard)

---

Top Contributors

[![scottbedard](https://avatars.githubusercontent.com/u/7980426?v=4)](https://github.com/scottbedard "scottbedard (10 commits)")

### Embed Badge

![Health badge](/badges/bedard-shipping/health.svg)

```
[![Health](https://phpackages.com/badges/bedard-shipping/health.svg)](https://phpackages.com/packages/bedard-shipping)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
