PHP IBGE Cidades: Find cities from Brazil using IBGE codes

Recommend this page to a friend!
  Info   View files Documentation   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2021-03-21 (6 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 18 All time: 10,379 This week: 227Up
Version License PHP version Categories
ibgecode-php 1.0BSD License7PHP 5, Geography
Description Author
This package is specific mainly for applications used in Brazil Brazil .

This package can be used to find cities from Brazil using IBGE codes.

It provides a trait that contains a list of all cities from Brazil associated to code numbers assigned by the official Brazilian institute for Geography (IBGE).

A separate class uses the trait to return the name and the state of a city giving its IBGE code.

In Portuguese:

Classe para retornar cidade e estado a partir de códigos IBGE fornecidos em array.

Picture of Carlos Artur Curvelo da Matos
  Performance   Level  
Name: Carlos Artur Curvelo da ... is available for providing paid consulting. Contact Carlos Artur Curvelo da ... .
Classes: 17 packages by
Country: Portugal Portugal
Age: 43
All time rank: 323241 in Portugal Portugal
Week rank: 224 Up6 in Portugal Portugal Up
Innovation award
Innovation award
Nominee: 11x

Winner: 2x

Details

ibgecode-php<br>

PHP Lint<br> Simple library to retrieve Brazilian city and respective state from the IBGE code.<br>

Installation

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

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.
  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (3 files)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file lint.yml Data Auxiliary data
  Accessible without login Plain text file main.yml Data Auxiliary data
  Accessible without login Plain text file php.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Plain text file Codes.php Class Class source
  Plain text file IBGE.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:18
This week:0
All time:10,379
This week:227Up
For more information send a message to info at phpclasses dot org.