flyingluscas / viacep-php
ViaCEP PHP SDK
Installs: 37 022
Dependents: 0
Suggesters: 0
Security: 0
Stars: 35
Watchers: 4
Forks: 12
Open Issues: 2
Requires
- php: ~5.6|~7.0
- ext-json: *
- guzzlehttp/guzzle: ~6.2
Requires (Dev)
- codeclimate/php-test-reporter: 0.3.*
- phpunit/phpunit: ~4.0||~5.0
- squizlabs/php_codesniffer: ~2.3
This package is auto-updated.
Last update: 2024-11-25 12:39:22 UTC
README
Search for addresses by zip code using the ViaCEP REST API.
Install
Via Composer
$ composer require flyingluscas/viacep-php
Usage
findByZipCode
Find address by zip code.
use FlyingLuscas\ViaCEP\ViaCEP; $viacep = new ViaCEP; $address = $viacep->findByZipCode('01001-000')->toArray(); /* Should return something like this: [ 'zipCode' => '01001-000', 'street' => 'Praça da Sé', 'complement' => 'lado ímpar', 'neighborhood' => 'Sé', 'city' => 'São Paulo', 'state' => 'SP', 'ibge' => '3550308', ] */ $address = $viacep->findByZipCode('01001-000')->toJson(); /* Should return something like this: { "zipCode": "01001-000", "street": "Praça da Sé", "complement": "lado ímpar", "neighborhood": "Sé", "city": "São Paulo", "state": "SP", "ibge": "3550308" } */
findByStreetName
Search for addresses using state, city and a street name.
use FlyingLuscas\ViaCEP\ViaCEP; $viacep = new ViaCEP; $addresses = $viacep->findByStreetName('SP', 'São Paulo', 'Gomes de Carvalho'); /* Should return something like this: [ [ 'zipCode' => '01001-000', 'street' => 'Praça da Sé', 'complement' => 'lado ímpar', 'neighborhood' => 'Sé', 'city' => 'São Paulo', 'state' => 'SP', 'ibge' => '3550308', ], [ 'zipCode' => '01001-000', 'street' => 'Praça da Sé', 'complement' => 'lado ímpar', 'neighborhood' => 'Sé', 'city' => 'São Paulo', 'state' => 'SP', 'ibge' => '3550308', ] ] */
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email lucas.pires.mattos@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.