alphazygma / usps-zonechart-php
Provide zone identification between Source and Target Destination.
Requires
- php: >=5.4
- guzzlehttp/guzzle: ~6
Requires (Dev)
- phpunit/phpunit: 3.7.*
- satooshi/php-coveralls: ~1.0
- symfony/config: ^2.1
- symfony/console: ^2.1
- symfony/filesystem: ^2.1
- symfony/stopwatch: ^2.0
This package is not auto-updated.
Last update: 2024-11-09 20:33:59 UTC
README
USPS ZoneChart (for PHP)
Provide zone identification between Source and Target Destination
Requirements
PHP 5.5+ is required. (The []
short array syntax was introduced on 5.4, and GuzzleHttp 6 is not compatible with PHP 5.4)
Disclaimer
The ConfigGenerator and the helper tool to run the generator does not have unittests, however, since these are not intended for library use, but more for updating the JSON configuration files if USPS updates their charts because new ZipCodes are added to the US.
As such, these files are not included for test coverage purposes.
Changelog
- 1.0 Retrieve a Zone for a given source/destination ZipCodes
Usage
This usage considers that you have an autoloader running. (see Install for more reference)
<?php
$sourceZip1 = '94040'; // Mountain View, CA
$sourceZip2 = '40342'; // Lawrenceburg, KY
$destinationZip = '94118'; // San Francisco, CA
// Same or close zone example (CA -> CA)
$zoneChart = new \Shipping\ZoneChart\ZoneChart($sourceZip1);
$zoneA = $zoneChart->getZoneFor($destinationZip);
// $zoneA would have 1 or 2 for example
// different zone example (KY -> CA)
$zoneChart = new \Shipping\ZoneChart\ZoneChart($sourceZip2);
$zoneB = $zoneChart->getZoneFor($destinationZip);
// $zoneB would have 4 or 5 for example
Install
The easiest way to install is through composer.
Just create a composer.json file for your project:
{ "require": { "alphazygma/usps-zonechart-php": "~1.0" } }
Then you can run these two commands to install it:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install
or simply run composer install
if you have have already installed the composer globally.
Then you can include the autoloader, and you will have access to the library classes:
<?php require 'vendor/autoload.php';