Download the PHP package brew/brazil-locations without Composer

On this page you can find all versions of the php package brew/brazil-locations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package brazil-locations

Brazil Locations

Latest Version on Packagist Total Downloads

English | Português

Laravel package that seeds all 27 Brazilian states and 5,570 municipalities into your database, with ready-to-use State and City Eloquent models and relationships. One composer require, one artisan command, done.

Every record carries its official IBGE code, so you can safely integrate with government APIs, NF-e/NFS-e issuers, shipping carriers and any other service that relies on IBGE identifiers.

Requirements

Installation

Require the package via Composer:

Run the install command:

That's it. The command will:

  1. Publish the migrations to database/migrations
  2. Run the migrations (states and cities tables)
  3. Publish the State and City models to app/Models
  4. Publish the StateSeeder and CitySeeder to database/seeders
  5. Run both seeders

Because the models and seeders are published into your application, you own them and are free to extend or customize them as you see fit.

Database schema

states

Column Type Notes
id bigint Primary key
name string e.g. São Paulo
uf string(2) Unique, e.g. SP
ibge_code string Unique, e.g. 35
timestamps

cities

Column Type Notes
id bigint Primary key
name string e.g. Campinas
state_id foreignId References states.id
ibge_code string Unique, e.g. 3509502
timestamps

Usage

Listing states

Cities of a state

State of a city

Eager loading

Typical use cases

Example: Filament dependent selects

Publishing assets individually

If you prefer to control each step instead of using the install command:

Re-seeding

The seeders use updateOrCreate keyed by ibge_code, so they are idempotent. Running them again will update existing records in place without creating duplicates.

Data source

States and municipalities are based on the official IBGE registry (Instituto Brasileiro de Geografia e Estatística).

Contributing

Contributions are welcome. Feel free to open an issue or submit a pull request at github.com/brew-apps/brazil-locations.

License

This package is open-sourced software licensed under the MIT license.


Português

English | Português

Package Laravel que popula seu banco de dados com os 27 estados e os 5.570 municípios do Brasil, com models Eloquent State e City e seus relacionamentos prontos para uso. Um composer require, um comando artisan, pronto.

Todos os registros incluem o código IBGE oficial, permitindo integração segura com APIs governamentais, emissores de NF-e/NFS-e, transportadoras e qualquer outro serviço que dependa de identificadores do IBGE.

Requisitos

Instalação

Instale o pacote via Composer:

Execute o comando de instalação:

Só isso. O comando irá:

  1. Publicar as migrations em database/migrations
  2. Executar as migrations (tabelas states e cities)
  3. Publicar os models State e City em app/Models
  4. Publicar os seeders StateSeeder e CitySeeder em database/seeders
  5. Executar os dois seeders

Como os models e seeders são publicados dentro da sua aplicação, eles passam a ser seus: você pode estendê-los ou customizá-los livremente.

Estrutura do banco

states

Coluna Tipo Observações
id bigint Chave primária
name string ex.: São Paulo
uf string(2) Único, ex.: SP
ibge_code string Único, ex.: 35
timestamps

cities

Coluna Tipo Observações
id bigint Chave primária
name string ex.: Campinas
state_id foreignId Referencia states.id
ibge_code string Único, ex.: 3509502
timestamps

Uso

Listar estados

Cidades de um estado

Estado de uma cidade

Eager loading

Casos de uso comuns

Exemplo: selects dependentes no Filament

Publicando os assets individualmente

Se preferir controlar cada etapa em vez de usar o comando de instalação:

Reexecutando os seeders

Os seeders utilizam updateOrCreate com base no ibge_code, portanto são idempotentes. Executá-los novamente atualiza os registros existentes sem criar duplicatas.

Fonte dos dados

Estados e municípios são baseados no cadastro oficial do IBGE (Instituto Brasileiro de Geografia e Estatística).

Contribuindo

Contribuições são bem-vindas. Abra uma issue ou envie um pull request em github.com/brew-apps/brazil-locations.

Licença

Este pacote é um software open source licenciado sob a licença MIT.


All versions of brazil-locations with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package brew/brazil-locations contains the following files

Loading the files please wait ...