Download the PHP package anglemx/mexico-postal-codes without Composer
On this page you can find all versions of the php package anglemx/mexico-postal-codes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download anglemx/mexico-postal-codes
More information about anglemx/mexico-postal-codes
Files in anglemx/mexico-postal-codes
Package mexico-postal-codes
Short Description PHP utility and database to lookup Mexico Postal Code information
License MIT
Homepage https://github.com/Angle/mexico-postal-codes
Informations about the package mexico-postal-codes
Angle Mexico Postal Codes
PHP utility and database to lookup Mexico Postal Code information
How to Use
Database Source
The database is downloaded from the official Correos de México website at: https://www.correosdemexico.gob.mx/SSLServicios/ConsultaCP/CodigoPostal_Exportar.aspx and it is then parsed and processed to optimize the filesize a bit.
Last database update: January 2, 2022
The database is published by SEPOMEX (SErvicio POstal MEXicano) and includes a Disclaimer Notice that allows personal use of the data but no commercial use at all. This must be honored by anybody using this PHP library:
El Catálogo Nacional de Códigos Postales, es elaborado por Correos de México y se proporciona en forma gratuita para uso particular, no estando permitida su comercialización, total o parcial, ni su distribución a terceros bajo ningún concepto.
Database Processing
To update and autogenerate, place the CPdescarga.txt
file inside the resources/
directory, then execute the ProcessSepomexPostalCodeDatabase.php
script.
- CPdescargatxt.zip -> 2MB compressed file
- CPdescarga.txt -> 14.6MB pipe-separated file
- mx-postal-codes.csv -> 6.94MB nested pipe-separated file
The column definitions can be found in this link: https://www.correosdemexico.gob.mx/SSLServicios/ConsultaCP/imagenes/Descrip.pdf
Database Analytics
We've included a very basic and barebones analytics script in AnalyticsSepomexPostalCodeDatabase.php
that parses the raw database and generates a few insights into the data.
Interesting facts from the Jan 2nd, 2022 database:
- There are 31,827 unique PostalCodes in Mexico
- PostalCode 85203 in Cajeme, Sonora, has 310 settlements registered in the same PostalCode.
Testing
TO-DO
- Implement "database expand" for PostalCodes to minimize the library install size. The current PostalCode database file weights 6.94MB, if we zip it we could reduce it to 1.6MB.
- The "SingleLookup" method for PostalCodes scans the file very quickly before parsing. This could be further optimized if the database file was ordered by "popularity", or at least by "cities first, rural second".
References
Some interesting tidbits from https://www.correosdemexico.gob.mx/DatosAbiertos/Normateca/SUS/LOG/LO7.pdf
- Los dos primeros dígitos identifican una entidad federativa y en el caso de la Ciudad de México una alcaldía.
- El tercer dígito identifica en las entidades federativas un conjunto de municipios, un municipio o parte de un municipio y en la Ciudad de México parte de una alcaldía
- El cuarto dígito identifica en las entidades federativas y en la Ciudad de México un conjunto de asentamientos humanos urbanos y rurales.
- El quinto dígito identifica en las entidades federativas y en la Ciudad de México un conjunto de asentamientos humanos urbanos y rurales o un asentamiento humano urbano rural o una oficina postal.
All versions of mexico-postal-codes with dependencies
ext-json Version *
ext-bcmath Version *
ext-intl Version *
ext-mbstring Version *