blancohugo/correios

使用PHP在Correios的SIGEP中查询CEP

v1.0 2018-09-11 21:16 UTC

This package is auto-updated.

Last update: 2024-09-26 09:24:33 UTC


README

Latest version CircleCI Code Coverage Download count

一个从提供的邮编中获取地址数据的服务的API。

安装

$ composer require blancohugo/correios

如何使用

以下是一个实现地址数据搜索的示例:

<?php

require 'vendor/autoload.php';

use BlancoHugo\Correios\Zipcode;
use BlancoHugo\Correios\Client;
use BlancoHugo\Correios\Exception;

$client = new Client();
$address = $client->query(new Zipcode('01311-929'));

客户端类使用异常处理数据。请确保您的代码可以处理以下情况:

<?php

try {
    $address = $client->query(new Zipcode('01311-929'));
} catch (Exception\InvalidZipcodeException $e) {
    // Invalid zipcode
} catch (Exception\ZipcodeNotFoundException $e) {
    // Address data not found
} catch (Exception\UnexpectedResponseException $e) {
    // Unexpected response from SIGEP
}

贡献

查看如何贡献 到此项目。