EasyPost is a simple shipping API. You can sign up for an account at https://easypost.com.
NOTE: Although this library has been tested with PHP 5.3^, it's highly recommended to use PHP 7.2^. Additionally, This library relies on the mbstring extension. Ensure you have it installed correctly before using the library.
Install the Library via Composer:
composer require easypost/easypost-php
Then, require the autoloader:
require_once("/path/to/vendor/easypost/autoload.php");
OR: Manually Install the Library
Manually download this library and require it from your project:
require_once("/path/to/lib/easypost.php");
Run the following from the root directory of the library:
composer install
require_once("/path/to/vendor/easypost/autoload.php");
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
$to_address = \EasyPost\Address::create(
array(
"name" => "Dr. Steve Brule",
"street1" => "179 N Harbor Dr",
"city" => "Redondo Beach",
"state" => "CA",
"zip" => "90277",
"phone" => "310-808-5243"
)
);
$from_address = \EasyPost\Address::create(
array(
"company" => "EasyPost",
"street1" => "118 2nd Street",
"street2" => "4th Floor",
"city" => "San Francisco",
"state" => "CA",
"zip" => "94105",
"phone" => "415-456-7890"
)
);
$parcel = \EasyPost\Parcel::create(
array(
"predefined_package" => "LargeFlatRateBox",
"weight" => 76.9
)
);
$shipment = \EasyPost\Shipment::create(
array(
"to_address" => $to_address,
"from_address" => $from_address,
"parcel" => $parcel
)
);
$shipment->buy($shipment->lowest_rate());
$shipment->insure(array('amount' => 100));
echo $shipment->postage_label->label_url;
Up-to-date documentation can be found at: https://www.easypost.com/docs.
- Update the
VERSION
file - Update the
CHANGELOG
file - Update the
VERSION
constant in theEasyPost.php
file - Update the version in the
composer.json
file - Create a git tag with the new version
Packagist should automatically pull in the new tag if the above was done properly.
NOTE: Unit tests only work with PHP 7.2^.
Ensure dependencies are installed, then run any of the following:
Fix PHP Standards:
./bin/php-cs-fixer fix mydir --verbose --show-progress=estimating
Run Linting:
./bin/phplint ./dir
Run Unit Tests:
./bin/phpunit