PHPackages                             carloswph/ibgecode-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. carloswph/ibgecode-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

carloswph/ibgecode-php
======================

Simple library to retrieve Brazilian city and respective state from the IBGE code.

v1.0.1(5y ago)310GPL-3.0-or-laterPHPPHP &gt;=7.0.1

Since Feb 5Pushed 5y ago1 watchersCompare

[ Source](https://github.com/carloswph/ibgecode-php)[ Packagist](https://packagist.org/packages/carloswph/ibgecode-php)[ RSS](/packages/carloswph-ibgecode-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)DependenciesVersions (4)Used By (0)

ibgecode-php

=============

[](#ibgecode-php)

[![PHP Lint](https://camo.githubusercontent.com/fdc8beb33e5f0a5af5baf503cca97b099a2eed4443b04b4851e3f6e057df03df/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502532304c696e742d7061737365642d677265656e)](https://github.com/carloswph/ibgecode-php/)
Simple library to retrieve Brazilian city and respective state from the IBGE code.

Installation
============

[](#installation)

Just require the library using Composer `composer require carloswph/ibgecode-php`.

Usage
=====

[](#usage)

Simply autoload and instantiate the IBGE class - including an array of the searched codes as parameter. From the initial instance, the class admits methods to get the respective city, the state or both. All methods return an array of results.

```
use WPH\IBGE\IBGE;

require __DIR__ . '/vendor/autoload.php';

$try = new IBGE(['5200050', '2300101', '99999999999']);
$try->getCity(); // return an array of city names for each code
$try->getState(); // return an array of state codes for those
$try->getBoth(); // return an array of arrays, each with key-value pairs for cities and state codes
```

An additional chained method is available to return JSON, as follows.

```
$try = new IBGE(['5200050', '2300101', '99999999999']);
$try->getCity(); // return an array of city names for each code
$json = $try->toJson();

echo $json;

// Results in:
// [{"cidade":"Abadia de Goi\u00e1s","estado":"GO"},{"cidade":"Abaiara","estado":"CE"},["C\u00f3digo Inexistente."]]
// The toJson() method admits the parameter true, which returns the JSON response in pretty print format.
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1928d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/13c91dcf5209989038da335ba42538fa84670bf27400f220d182a76e0a720b74?d=identicon)[carloswph](/maintainers/carloswph)

---

Top Contributors

[![carloswph](https://avatars.githubusercontent.com/u/78516217?v=4)](https://github.com/carloswph "carloswph (11 commits)")[![meuppt](https://avatars.githubusercontent.com/u/37983141?v=4)](https://github.com/meuppt "meuppt (8 commits)")

---

Tags

brazilbrasilbrazilianibge

### Embed Badge

![Health badge](/badges/carloswph-ibgecode-php/health.svg)

```
[![Health](https://phpackages.com/badges/carloswph-ibgecode-php/health.svg)](https://phpackages.com/packages/carloswph-ibgecode-php)
```

###  Alternatives

[cagartner/correios-consulta

Package para pesquisa de serviços de busca por cep, calculo de frete e etc, diretamente nos serviços dos Correios.

159301.8k](/packages/cagartner-correios-consulta)[wgenial/numeroporextenso

Converte numeral em valor por extenso.

4666.9k](/packages/wgenial-numeroporextenso)[flyingluscas/viacep-php

ViaCEP PHP SDK

3640.2k](/packages/flyingluscas-viacep-php)[jansenfelipe/cidades-gratis

Com esse pacote você poderá consultar, gratuitamente, Cidades diretamente no site do IBGE.

423.5k](/packages/jansenfelipe-cidades-gratis)[lsnepomuceno/laravel-brazilian-ceps

A package for querying zip codes for Brazilian addresses.

322.4k](/packages/lsnepomuceno-laravel-brazilian-ceps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
