Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/treblatechnologies/zipcode

A PHP library to search the address data for a given zip code.
https://github.com/treblatechnologies/zipcode

Last synced: about 12 hours ago
JSON representation

A PHP library to search the address data for a given zip code.

Awesome Lists containing this project

README

        

# ZipCode PHP

A PHP library to search the address data for a given zip code.

# Getting Started

## Installation

Using Composer:

``` bash
composer require trebla/zipcode
```

## How to use

You can search for a zip code passing it as a parameter to `find()` method:

``` php
use Trebla\ZipCode\ZipCode;
use Trebla\ZipCode\Entities\ZipCodeEntity;

public function getAddress(string $zipcode): ZipCodeEntity
{
return ZipCode::find($zipcode);
}
```

You also can choose the zip code service passing it as a parameter to `find()` method:

``` php
use Trebla\ZipCode\ZipCode;
use Trebla\ZipCode\Entities\ZipCodeEntity;
use Trebla\ZipCode\Helpers\ZipCodeHelper;

public function getAddress(string $zipcode): ZipCodeEntity
{
return ZipCode::find($zipcode, ZipCodeHelper::VIA_CEP);
}
```

## Services available

| Service | Constant | Default |
| ------ | ------ | ------ |
| Pagar me | `ZipCodeHelper::PAGAR_ME` | X |
| Repúblic Virtual | `ZipCodeHelper::REPUBLICA_VIRTUAL` | |
| Via CEP | `ZipCodeHelper::VIA_CEP` | |