PHPackages                             rairlie/postage-calculator - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. rairlie/postage-calculator

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

rairlie/postage-calculator
==========================

Calculate postage costs for a parcel

v1.1.0(5y ago)4451MITPHPPHP &gt;=7.0.0

Since Jan 9Pushed 5y ago1 watchersCompare

[ Source](https://github.com/rairlie/postage-calculator)[ Packagist](https://packagist.org/packages/rairlie/postage-calculator)[ RSS](/packages/rairlie-postage-calculator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

postage-calculator [![Build Status](https://camo.githubusercontent.com/aa0b90793a1b72c5672a57f44de5855bf759fe186d4d935fe94a5d63848c5f9d/68747470733a2f2f7472617669732d63692e6f72672f726169726c69652f706f73746167652d63616c63756c61746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/rairlie/postage-calculator) [![Coverage Status](https://camo.githubusercontent.com/a7ea5b878c0996c749ba1353cd67726a01e91ad92de8a7d27d00c1c2f15daa25/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f726169726c69652f706f73746167652d63616c63756c61746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/rairlie/postage-calculator?branch=master)
=========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#postage-calculator--)

Calculates price for UK postal services

Requires
--------

[](#requires)

PHP 7.0+

Installation
------------

[](#installation)

```
$ composer require rairlie/postage-calculator

```

Usage
-----

[](#usage)

```
use Rairlie\PostageCalculator\PostageCalculator;
use Rairlie\PostageCalculator\ParcelForce;

// Calculate postage for a Royal Mail parcel
$postageCalculator = new PostageCalculator();
$price = $postageCalculator
    ->getService(PostageCalculator::SERVICE_ROYAL_MAIL)
    ->getPrice(
        450, // Weight in grams
        [10, 22, 8] // Dimensions in cm - length, width, depth
    );

// Calculate postage for a Parcelforce parcel
$price = $postageCalculator
    ->getService(PostageCalculator::SERVICE_PARCELFORCE_24)
    ->getPrice(
        450, // Weight in grams
        ParcelForce::METHOD_DROP_POST_OFFICE
    );

```

Parcelforce parcels can be sent by four methods:

- ParcelForce::METHOD\_COLLECT - Parcel to be collected from a pick-up address
- ParcelForce::METHOD\_DROP\_POST\_OFFICE - Parcel to be dropped at a PostOffice
- ParcelForce::METHOD\_DROP\_DEPOT - Parcel to be dropped at a depot
- ParcelForce::METHOD\_DEPOT\_TO\_DEPOT - Parcel to be dropped at and collected from a depot

Configuration
-------------

[](#configuration)

The prices are derived from configuration files in **src/Defaults:**

```
src/Defaults/RoyalMail.php
src/Defaults/ParcelForce24.php
src/Defaults/ParcelForce48.php

```

The format should be fairly self-explanatory, and prices are correct as of January 2018. If you need to customise them, for example to load them from a DB or to facilitate unit testing, you can pass your own price configs into the constructor:

```
$postageCalculator = new PostageCalculator([
    PostageCalculator::SERVICE_ROYAL_MAIL => $myRoyalMailPrices,
    PostageCalculator::SERVICE_PARCELFORCE_24 => $myParcelForce24Prices,
    PostageCalculator::SERVICE_PARCELFORCE_48 => $myParcelForce48Prices,
]);

```

Exceptions
----------

[](#exceptions)

The following exceptions may be thrown:

- ParcelTooHeavyException - the parcel is too heavy to send with the service
- ParcelTooLargeException - the parcel is too large (dimensions) to send with the service
- MethodUnavailableException - its not possible to use the specified delivery method to send this parcel (Parcelforce only)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~1048 days

Total

2

Last Release

1996d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec941d9d8db5ace4b26fed68f86aa158f95702af69b88faae1fb669b5a1a1b9d?d=identicon)[rairlie](/maintainers/rairlie)

---

Top Contributors

[![rairlie](https://avatars.githubusercontent.com/u/14072280?v=4)](https://github.com/rairlie "rairlie (32 commits)")

---

Tags

calculatorpostage

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/rairlie-postage-calculator/health.svg)

```
[![Health](https://phpackages.com/badges/rairlie-postage-calculator/health.svg)](https://phpackages.com/packages/rairlie-postage-calculator)
```

###  Alternatives

[markrogoyski/ipv4-subnet-calculator

Network calculator for subnet mask and other classless (CIDR) network information.

177813.7k6](/packages/markrogoyski-ipv4-subnet-calculator)[ballen/distical

A distance (Lat/Long) calculation library for PHP

40180.2k2](/packages/ballen-distical)

PHPackages © 2026

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