PHPackages                             ajangsupardi/laravel-kodepos - 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. [Database &amp; ORM](/categories/database)
4. /
5. ajangsupardi/laravel-kodepos

ActiveLibrary[Database &amp; ORM](/categories/database)

ajangsupardi/laravel-kodepos
============================

Laravel package for seeding Indonesian address data (provinces, regencies, districts, villages) with postal codes from Pos Indonesia

00PHPCI passing

Since Jun 19Pushed todayCompare

[ Source](https://github.com/ajangsupardi/laravel-kodepos)[ Packagist](https://packagist.org/packages/ajangsupardi/laravel-kodepos)[ RSS](/packages/ajangsupardi-laravel-kodepos/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (1)Used By (0)

Laravel Kodepos
===============

[](#laravel-kodepos)

[![Latest Stable Version](https://camo.githubusercontent.com/449d7cf2ba81fcd88c1bd3efdf8eabedc603816ecbbf210e7117dfd1429d1da9/68747470733a2f2f706f7365722e707567782e6f72672f616a616e67737570617264692f6c61726176656c2d6b6f6465706f732f762f737461626c65)](https://packagist.org/packages/ajangsupardi/laravel-kodepos)[![License](https://camo.githubusercontent.com/eb58b4e98d304cf7341540456122f873d0a2f03d3dac632f51f9c48ef172ad6b/68747470733a2f2f706f7365722e707567782e6f72672f616a616e67737570617264692f6c61726176656c2d6b6f6465706f732f6c6963656e7365)](https://packagist.org/packages/ajangsupardi/laravel-kodepos)[![Total Downloads](https://camo.githubusercontent.com/cf3de22b54be39d764ab872bb863e68ba825b27d8d0b9d18b34e14c677becf01/68747470733a2f2f706f7365722e707567782e6f72672f616a616e67737570617264692f6c61726176656c2d6b6f6465706f732f646f776e6c6f616473)](https://packagist.org/packages/ajangsupardi/laravel-kodepos)

Laravel package for downloading and seeding Indonesian address data (provinces, regencies, districts, villages) with postal codes from the official Pos Indonesia website.

Features
--------

[](#features)

- Auto-download kodepos data from [Pos Indonesia](https://kodepos.posindonesia.co.id)
- Hierarchical data parsing: Province → Regency → District → Village
- Ready-to-use database seeders
- Migration files included
- Configurable and extendable Eloquent models
- Supports Laravel 11, 12, and 13

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

[](#installation)

```
composer require ajangsupardi/laravel-kodepos
```

### Publish Configuration (optional)

[](#publish-configuration-optional)

```
php artisan vendor:publish --tag=kodepos-config
```

### Publish Migrations (optional)

[](#publish-migrations-optional)

```
php artisan vendor:publish --tag=kodepos-migrations
```

> **Note:** Migrations are automatically loaded by the service provider, so publishing is only needed if you want to modify the table structure.

Usage
-----

[](#usage)

### 1. Download Kodepos Data

[](#1-download-kodepos-data)

```
php artisan kodepos:download
```

This command will download all kodepos data from Pos Indonesia and save it as a CSV file.

### 2. Run the Seeder

[](#2-run-the-seeder)

```
php artisan db:seed --class=Ajangsupardi\Kodepos\Database\Seeders\KodeposSeeder
```

Or add it to your `DatabaseSeeder.php`:

```
use Ajangsupardi\Kodepos\Database\Seeders\KodeposSeeder;

public function run(): void
{
    $this->call([
        KodeposSeeder::class,
    ]);
}
```

### 3. Auto-download &amp; Seed

[](#3-auto-download--seed)

If you want to combine download and seed in a single step, you can call the download command before the seeder:

```
use Illuminate\Support\Facades\Artisan;

$storagePath = config('kodepos.storage_path');
if (! file_exists($storagePath.'/kodepos.csv')) {
    Artisan::call('kodepos:download');
}
```

Database Tables
---------------

[](#database-tables)

This package creates 4 tables:

TableDescription`provinces`Province data (id, name, code)`regencies`Regency/city data (id, province\_id, name)`districts`District/sub-district data (id, regency\_id, name)`villages`Village data (id, district\_id, name, postal\_code)Configuration
-------------

[](#configuration)

Edit `config/kodepos.php`:

```
return [
    // CSV file storage path
    'storage_path' => storage_path('app/kodepos'),

    // Database table prefix (null = no prefix)
    'table_prefix' => null,

    // Custom models
    'models' => [
        'province' => Ajangsupardi\Kodepos\Models\Province::class,
        'regency'  => Ajangsupardi\Kodepos\Models\Regency::class,
        'district' => Ajangsupardi\Kodepos\Models\District::class,
        'village'  => Ajangsupardi\Kodepos\Models\Village::class,
    ],

    // HTTP client settings
    'http' => [
        'timeout' => 60,
        'connect_timeout' => 10,
        'retry' => 3,
        'retry_delay' => 1000,
        'user_agent' => 'Mozilla/5.0 (compatible; LaravelKodepos/1.0)',
    ],
];
```

### Custom Models

[](#custom-models)

You can extend the default models to add columns or relationships:

```
namespace App\Models;

use Ajangsupardi\Kodepos\Models\Province as BaseProvince;

class Province extends BaseProvince
{
    protected $fillable = ['name', 'code', 'your_custom_field'];

    // Add custom relationships or methods
}
```

Then update the configuration:

```
'models' => [
    'province' => App\Models\Province::class,
],
```

### Table Prefix

[](#table-prefix)

If you want to use a prefix for your tables:

```
'table_prefix' => 'kodepos_',
```

This will create tables: `kodepos_provinces`, `kodepos_regencies`, `kodepos_districts`, `kodepos_villages`.

Example Queries
---------------

[](#example-queries)

```
use Ajangsupardi\Kodepos\Models\Province;
use Ajangsupardi\Kodepos\Models\Village;

// Get all provinces
$provinces = Province::all();

// Get regencies in East Java
$regencies = Province::where('name', 'Jawa Timur')
    ->first()
    ->regencies;

// Find a village by postal code
$village = Village::where('postal_code', '60111')->first();

// Get full address hierarchy from village to province
$village = Village::with('district.regency.province')
    ->where('postal_code', '60111')
    ->first();
```

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

[](#requirements)

- PHP ^8.2
- Laravel ^11.0 / ^12.0 / ^13.0

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for more information.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35716844?v=4)[ᑎᗩᒍ](/maintainers/ajangsupardi)[@ajangsupardi](https://github.com/ajangsupardi)

---

Top Contributors

[![ajangsupardi](https://avatars.githubusercontent.com/u/35716844?v=4)](https://github.com/ajangsupardi "ajangsupardi (2 commits)")

---

Tags

address-datacomposerdatabase-seederindonesiakodeposlaravelpackagistpostal-code

### Embed Badge

![Health badge](/badges/ajangsupardi-laravel-kodepos/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[yemenopensource/filament-excel

This package useful for importing excel files into models.

194.2k](/packages/yemenopensource-filament-excel)

PHPackages © 2026

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