Skip to content

This is an ziptastic client for php using guzzle with two ways to use it.

Notifications You must be signed in to change notification settings

Ziptastic/ziptastic-php-fluent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ziptastic PHP with Guzzle

This package was brought into existence because of this package, specifically because of the first enhancement

This library is a Guzzle based interface for the Ziptastic API.

Using Ziptastic requires an API key, you can get one by signing up with Ziptastic.

Installing

Ziptastic PHP can be installed via composer:

composer require ziptastic/fluent

Usage

There are two different ways to use this package with the same end result.

The first way to use this is by using Zipper which will be using a more "plain english" oriented syntax

<?php

include "vendor/autoload.php";

use Ziptastic\Fluent\Zipper;

$key = 'Your Api Key from ziptastic';

$results = (new Zipper)->in('US')->withPostalCode(48867)->andWithKey($key)->find();
echo $results->response;
?>

If that isn't your cup of tea or you just want to get things done, you can use Ziptastic

<?php

include "vendor/autoload.php";

use Ziptastic\Fluent\Ziptastic;

$key = 'Your Api Key from ziptastic';

$results = (new Ziptastic(23042,'us'))->setKey($key)->find();

echo $results->response;
?>

Using results

If you wanted to, you can access any and all of the results of the api call via calling the item you want from the api response. The first way to use this is by using Zipper which will be using a more "plain english" oriented syntax

<?php

include "vendor/autoload.php";

use Ziptastic\Fluent\Zipper;

$key = 'Your Api Key from ziptastic';

$results = (new Zipper)->in('US')->withPostalCode(48867)->andWithKey($key)->find();
echo $results->city, ', ',$results->state,' ',$results->postal_code;
?>

And in that example the only one set by default is the postal code, the others are from the response.

Ziptastic PHP is licensed under the MIT license.