EasyPost is a simple shipping API. You can sign up for an account at https://easypost.com.
NOTE: Although this library may work with PHP 5.3^, it is only tested against PHP 7.2^ and we 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-phpThen, 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 installrequire_once("/path/to/vendor/easypost/autoload.php");
\EasyPost\EasyPost::setApiKey('API_KEY');
$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
VERSIONfile - Update the
CHANGELOGfile - Update the
VERSIONconstant in theEasyPost.phpfile - Update the version in the
composer.jsonfile - 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:
# Lint project
composer lint
# Fix linting errors
composer fix
# Run tests
composer test