Package Data | |
---|---|
Maintainer Username: | johnpaulmedina |
Maintainer Contact: | jp@leadtrust.io (John Paul Medina) |
Package Create Date: | 2016-05-12 |
Package Last Update: | 2023-11-20 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-08 03:02:59 |
Package Statistics | |
---|---|
Total Downloads: | 19,837 |
Monthly Downloads: | 490 |
Daily Downloads: | 24 |
Total Stars: | 19 |
Total Watchers: | 6 |
Total Forks: | 28 |
Total Open Issues: | 0 |
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
Begin by installing this package through Composer. Run this command from the Terminal:
composer require johnpaulmedina/laravel-usps
For Laravel 5.5 and later, this package will be auto discovered and registered.
To wire this up in your Laravel 5.4 project you need to add the service provider.
Open config/app.php
, and add a new item to the providers array.
Johnpaulmedina\Usps\UspsServiceProvider::class,
Then you must also specify the alias in config/app.php
. Add a new item to the Aliases array.
'Usps' => Johnpaulmedina\Usps\Facades\Usps::class,
This will allow integration by adding the Facade Use Usps;
Add your USPS username config in config/services.php
.
'usps' => [
'username' => "XXXXXXXXXXXX",
'testmode' => false,
],
The only method completed for Laravel is the Usps::validate
which is defined in vendor/johnpaulmedina/laravel-usps/src/Usps/Usps.php
. As this package was developed for internal use I did not bring over all the features but you are more than welcome to contribute the methods you need and I will merge them. 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() {
return response()->json(
Usps::validate(
Request::input('Address'),
Request::input('Zip'),
Request::input('Apartment'),
Request::input('City'),
Request::input('State')
)
);
}
public function trackConfirm() {
return response()->json(
Usps::trackConfirm(
Request::input('id')
)
);
}
public function trackConfirmRevision1() {
return response()->json(
Usps::trackConfirm(
Request::input('id'),
'Acme, Inc'
)
);
}
}
@VinceG Original README.MD
This wrapper allows you to perform some basic calls to the USPS api. Some of the features currently supported are:
@pdbreen