PHPackages                             wafto/laravel-sepomex - 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. wafto/laravel-sepomex

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

wafto/laravel-sepomex
=====================

Servicio Postal Mexicano (Sepomex) not official laravel library

v4.1.0(6mo ago)75.7k6MITPHPPHP ^8.2CI failing

Since Nov 9Pushed 6mo agoCompare

[ Source](https://github.com/wafto/laravel-sepomex)[ Packagist](https://packagist.org/packages/wafto/laravel-sepomex)[ RSS](/packages/wafto-laravel-sepomex/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (8)Versions (20)Used By (0)

Laravel Sepomex
===============

[](#laravel-sepomex)

[![Total Downloads](https://camo.githubusercontent.com/755f10d465e67d7c62255ea85032c52b5400a26b31ef1a5d45f21b4cdec283da/68747470733a2f2f706f7365722e707567782e6f72672f776166746f2f6c61726176656c2d7365706f6d65782f646f776e6c6f616473)](https://packagist.org/packages/wafto/laravel-sepomex)[![Latest Stable Version](https://camo.githubusercontent.com/acb066192b6648cb814d5459997ad8f831971fb78f8137d86a873a1c713c59d5/68747470733a2f2f706f7365722e707567782e6f72672f776166746f2f6c61726176656c2d7365706f6d65782f762f737461626c65)](https://packagist.org/packages/wafto/laravel-sepomex)[![License](https://camo.githubusercontent.com/ca582079e7397ecb487287754fb8c2bb927951044d84d9fd6ae53433955d76ac/68747470733a2f2f706f7365722e707567782e6f72672f776166746f2f6c61726176656c2d7365706f6d65782f6c6963656e7365)](https://packagist.org/packages/wafto/laravel-sepomex)

Introduction
------------

[](#introduction)

Laravel Sepomex is a package that provides Mexican postal code ([SEPOMEX](https://www.correosdemexico.gob.mx)) lookup functionality for Laravel applications. It imports postal code data from the official "Correos de México" catalog and provides an API to query settlements by postal code or list all states.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10, 11, or 12

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require wafto/laravel-sepomex
```

Setup
-----

[](#setup)

### 1. Publish Configuration

[](#1-publish-configuration)

Publish the `sepomex.php` configuration file:

```
php artisan vendor:publish --provider="Wafto\Sepomex\SepomexServiceProvider"
```

This will create a configuration file at `config/sepomex.php` where you can customize the `table_name` and `source_file` options.

### 2. Download Source File

[](#2-download-source-file)

Download the official SEPOMEX catalog from [Correos de México](https://www.correosdemexico.gob.mx/SSLServicios/ConsultaCP/CodigoPostal_Exportar.aspx) and save it to your `storage` directory as `cpdescarga.txt`.

The file path should match the `source_file` setting in your configuration.

### 3. Run Migrations

[](#3-run-migrations)

Run the database migrations to create the required table:

```
php artisan migrate
```

### 4. Import Data

[](#4-import-data)

Import the postal code data using the artisan command:

```
php artisan sepomex:import --chunk=50
```

The `--chunk` option controls the batch size for database inserts. This process may take several minutes depending on your system.

Usage
-----

[](#usage)

### Using Dependency Injection (Recommended)

[](#using-dependency-injection-recommended)

Inject the `SepomexContract` interface into your controllers or services:

```
use Wafto\Sepomex\Contracts\SepomexContract;

class SepomexController extends Controller
{
    public function postal(SepomexContract $sepomex, string $postal)
    {
        return $sepomex->getByPostal($postal);
    }

    public function states(SepomexContract $sepomex)
    {
        return $sepomex->getStates();
    }
}
```

### Using the Facade

[](#using-the-facade)

Alternatively, register the Sepomex facade in `config/app.php`:

```
'aliases' => [
    // ...
    'Sepomex' => Wafto\Sepomex\Facades\Sepomex::class,
]
```

Then use it anywhere in your application:

```
use Sepomex;

class SepomexController extends Controller
{
    public function postal(string $postal)
    {
        return Sepomex::getByPostal($postal);
    }

    public function states()
    {
        return Sepomex::getStates();
    }
}
```

### Using the Container

[](#using-the-container)

You can also resolve the contract from the container:

```
$sepomex = app(\Wafto\Sepomex\Contracts\SepomexContract::class);
$settlements = $sepomex->getByPostal('06600');
```

API Methods
-----------

[](#api-methods)

MethodDescription`getByPostal(string $postal)`Returns all settlements matching the given postal code`getStates()`Returns a list of all Mexican statesImportant Notes
---------------

[](#important-notes)

The database is distributed by Correos de México with the following clause:

> *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.*

The database has also been released under the [LIBRE USO MX](https://datos.gob.mx/libreusomx) license.

Source
------

[](#source)

> **"Catálogo Nacional de Códigos Postales"** publicado por Correos de México. Disponible en [https://www.correosdemexico.gob.mx/SSLServicios/ConsultaCP/CodigoPostal\_Exportar.aspx](https://www.correosdemexico.gob.mx/SSLServicios/ConsultaCP/CodigoPostal_Exportar.aspx)

License
-------

[](#license)

Laravel Sepomex is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance68

Regular maintenance activity

Popularity28

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.1% 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 ~167 days

Recently: every ~444 days

Total

19

Last Release

190d ago

Major Versions

v1.8 → v2.0.02021-03-24

v2.0.0 → v3.0.02024-07-09

v3.0.0 → v4.0.02026-01-30

PHP version history (6 changes)v1.0.0PHP &gt;=7.0

v1.4.0PHP ^7.2

v1.7.0PHP ^7.3

v1.8PHP ^8.0|^7.3

v2.0.0PHP ^8.0|^7.4

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e1f97dfc6b00e05c6ea9ca3ee967574d5aad79c9d5937d59f4bf31c08066b2f?d=identicon)[wafto](/maintainers/wafto)

---

Top Contributors

[![wafto](https://avatars.githubusercontent.com/u/514985?v=4)](https://github.com/wafto "wafto (68 commits)")[![jlozano254](https://avatars.githubusercontent.com/u/8600559?v=4)](https://github.com/jlozano254 "jlozano254 (2 commits)")

---

Tags

laravelmexicosepomexwafto

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/wafto-laravel-sepomex/health.svg)

```
[![Health](https://phpackages.com/badges/wafto-laravel-sepomex/health.svg)](https://phpackages.com/packages/wafto-laravel-sepomex)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45844.8k1](/packages/pressbooks-pressbooks)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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