PHP code example of claudsonm / cep-promise-php
1. Go to this page and download the library: Download claudsonm/cep-promise-php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
claudsonm / cep-promise-php example snippets
use Claudsonm\CepPromise\CepPromise;
Claudsonm\CepPromise\Address Object
(
[city] => Aracaju
[district] => Inácio Barbosa
[state] => SE
[street] => Rua Universo
[zipCode] => 49040610
)
*/
use Claudsonm\CepPromise\CepPromise;
oArray();
/*
Array
(
[city] => Rondonópolis
[district] => Vila Marinópolis
[state] => MT
[street] => Rua Pirajuí
[zipCode] => 78710857
)
*/
use Claudsonm\CepPromise\CepPromise;
echo $address->zipCode;
echo $address->street;
echo $address->district;
echo $address->city;
echo $address->state;
/*
'59067540'
'Rua Figueira'
'Pitimbu'
'Natal'
'RN'
*/
use Claudsonm\CepPromise\CepPromise;
use Claudsonm\CepPromise\Exceptions\CepPromiseException;
e = $e->toArray();
}
/*
Array
(
[message] => Todos os serviços de CEP retornaram erro.
[code] => 2
[errors] => Array
(
[0] => Array
(
[provider] => via_cep
[message] => CEP não encontrado na base do ViaCEP.
)
[1] => Array
(
[provider] => cep_aberto
[message] => Erro ao se conectar com o serviço CEP Aberto.
)
[2] => Array
(
[provider] => correios
[message] => CEP INVÁLIDO
)
)
)
*/
bash
composer