Search by

saade / cep-php

saade

Async, high availability brazilian CEP finder with multiple providers for redundancy.

Package info

github.com/saade/cep-php

pkg:composer/saade/cep-php

Fund package maintenance!

saade

Statistics

Installs: 7 729

Dependents: 0

Suggesters: 0

Stars: 7

Open Issues: 0

v2.0.0 2026-10-13 16:58 UTC

This package is auto-updated.

Last update: 2026-10-21 20:53:15 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads Plumb score

Installation

You can install the package via composer:

composer require saade/cep-php

Usage

use Saade\Cep\Cep;

$cep = Cep::get('28895-190');

$cep->cep; // 28895190
$cep->state; // RJ
$cep->city; // Rio das Ostras
$cep->neighborhood; // Costazul
$cep->street; // Rua Nelson Pecegueiro do Amaral
$cep->provider; // open-cep / correios / viacep / widenet / correios-alt / brasil-api

Cep::get() returns null when no provider can resolve the CEP.

How it works

  1. OpenCEP is queried first.
  2. If it can't resolve the CEP, Correios, ViaCEP, WideNet, Correios (alt) and BrasilAPI are queried concurrently and the first one to answer wins.

You may also race the providers of your choice:

use Saade\Cep\Cep;
use Saade\Cep\Providers\BrasilApiProvider;
use Saade\Cep\Providers\ViaCepProvider;

$cep = Cep::race('28895-190', [ViaCepProvider::class, BrasilApiProvider::class]);

Or query a single one, which throws when the CEP can't be resolved:

use Saade\Cep\Providers\ViaCepProvider;

$cep = ViaCepProvider::get('28895-190');

Testing

composer test

composer test:live runs the suite that hits the real providers.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.