wbraganca/yii2-correios

Locates an address in Brazil by postal code

Installs: 113

Dependents: 0

Suggesters: 0

Stars: 0

Watchers: 1

Forks: 2

Open Issues: 0

Type:yii2-extension

1.0.0-alpha.2 2016-05-25 14:46 UTC

README

Latest Version Software License Total Downloads

Install

Via Composer

$ composer require wbraganca/yii2-correios

or add

"wbraganca/yii2-correios": "dev-master"

to the require section of your composer.json file.

Usage

###Raw search.

<?php

use wbraganca\correios\AddressSearchByCep;

$obj = new AddressSearchByCep();
$result = $obj->search('22021-001');
/* OUTPUT
array(
    'location' => 'Avenida Atlântica - de 1662 a 2172 - lado pa'
    'district' => 'Copacabana'
    'city' => 'Rio de Janeiro'
    'state' => 'RJ'
    'cep' => '22021-001'
    'result' => 1
    'result_text' => 'Address found.'
);
*/

###On your controller.

public function actions()
{
    return [
        'searchAddress' => 'wbraganca\correios\CepAction'
    ];
}

http://example.com/index.php?r=your-controller/searchAddress&cep=22021-001