2017 © Pedro Peláez
 

library laravel-usps

USPS API for Laravel 5

image

mpinchuk/laravel-usps

USPS API for Laravel 5

  • Wednesday, February 22, 2017
  • by mpinchuk
  • Repository
  • 2 Watchers
  • 4 Stars
  • 429 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 50 % Grown

The README.md

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, (*1)

  • Requires a valid USPS API Username
  • Tested on Laravel 5+

Installation

Begin by installing this package through Composer. Run this command from the Terminal:, (*2)

composer require mpinchuk/laravel-usps: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., (*3)

'Usps\UspsServiceProvider',

Then you must also specify the alias in config/app.php. Add a new item to the Aliases array., (*4)

'Usps' => 'Usps\Facades\Usps',

This will allow integration by adding the Facade Use Usps;, (*5)

Laravel Config

Add your USPS username config in config/services.php., (*6)

'usps' => [
        'username' => "XXXXXXXXXXXX"
    ]

Example Controller Usage

The only method completed for Laravel is the Usps::validate which is defined in vendor/mpinchuk/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., (*7)

<?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')
            )
        );
    }
}

@VinceG Original README.MD, (*8)

USPS PHP API

This wrapper allows you to perform some basic calls to the USPS api. Some of the features currently supported are:, (*9)

  • 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

The Versions

22/02 2017

dev-master

9999999-dev https://github.com/johnpaulmedina/laravel-usps/

USPS API for Laravel 5

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by John Paul Medina

laravel usps laravel5 laravel usps