mutahir-shah / uspslaravel
This version is a modified version of https://github.com/johnpaulmedina/laravel-usps
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2025-04-05 15:51:24 UTC
README
Updated version of below package. Updates are done by mutahir@pkteam.com. Laravel-USPS updated package of https://github.com/johnpaulmedina/laravel-usps.
Laravel-USPS is a composer package that allows you to integrate the USPS Address / Shipping API. This backage is ported from @author Vincent Gabriel https://github.com/VinceG/USPS-php-api
- Requires a valid USPS API Username
- Tested on Laravel 5+
Installation
Begin by installing this package through Composer. Run this command from the Terminal:
composer require mutahir-shah/uspslaravel:dev-master
Laravel integration
To wire this up in your Laravel project you need to add the service provider.
Open config/app.php
, and add a new item to the providers array.
'Usps\UspsServiceProvider',
Then you must also specify the alias in config/app.php
. Add a new item to the Aliases array.
'Usps' => 'Usps\Facades\Usps',
This will allow integration by adding the Facade Use Usps;
Laravel Config
Add your USPS username config in config/services.php
.
'usps' => [ 'username' => "XXXXXXXXXXXX" ]
Example Controller Usage
The only method completed for Laravel is the Usps::validate
,getPriorityLabels,calculateRates which is defined in vendor/johnpaulmedina/laravel-usps/src/Usps/Usps.php
. I am adding more methods in it. I suggest looking at the original PHP-Wrapper by @VinceG USPS PHP-Api as I ported those clases and autoloaded them to use in the Usps.php
file.
<?php namespace app\Http\Controllers; use app\Http\Requests; use app\Http\Controllers\Controller; use Illuminate\Support\Facades\Request; use Usps; class USPSController extends Controller { public function index() { $response = response()->json( Usps::getPriorityLabels(['Apartment'=>'','Address'=>'10113 Condor Loop','Zip'=>'76708','City'=>'Waco','State'=>'TX'])); } }
@VinceG Original README.MD
USPS PHP API
This wrapper allows you to perform some basic calls to the USPS api. Some of the features currently supported are:
- Rate Calculator (Both domestic and international)
- Zip code lookup by address
- City/State lookup by zip code
- Verify address
- Create Priority Shipping Labels
- Create Open & Distribute Shipping Labels
- Create International Shipping Labels (Express, Priority, First Class)
- Service Delivery Calculator
- Confirm Tracking
Requirements
- PHP >= 5.4 configured with the following extensions:
- cURL
- USPS API Username
Authors
- Vincent Gabriel http://vadimg.com (Original PHP-Wrapper)
Furthere modifications and enhancement for laravel are done by , Mutahir Shah http://pkteam.com