Search by

truckleap / haul-cost

truckleap

Small PHP helpers for trucking cost math: cost per mile, deadhead share and fuel cost for a lane.

dev-main 2026-10-25 06:08 UTC

This package is not auto-updated.

Last update: 2026-11-09 04:32:52 UTC


README

Tiny, dependency-free PHP helpers for the numbers a small trucking carrier checks before saying yes to a load.

use TruckLeap\HaulCost\HaulCost;

HaulCost::costPerMile(4200, 6100, 9800);      // 1.051 dollars per mile
HaulCost::deadheadShare(120, 880);            // 0.12
HaulCost::fuelCost(880, 6.5, 3.89);           // 526.65
HaulCost::allInRatePerMile(2400, 880, 120);   // 2.4

Install with composer require truckleap/haul-cost.

Why the all-in rate matters

A posted rate is quoted on loaded miles only. The miles you drive empty to reach the shipper are paid by the same check, so the honest number is the linehaul divided by every mile on the trip. The allInRatePerMile helper does exactly that.

If you'd rather punch the numbers into a form than write code, there's a browser version of the cost-per-mile math that does the same thing.

MIT licensed. Maintained by George Green at TruckLeap.