layout: default title: Getting Started nav_order: 2 —

Getting Started

Table of contents

  1. Installation
  2. Publish Assets
    1. Configuration (optional)
    2. Migrations (optional)
  3. Database Setup
  4. Seed Database
  5. Update Data (Optional)
  6. What’s Next?

Installation

Requirements: PHP ^8.3 and Laravel ^11.0 / ^12.0 / ^13.0

Install the package via Composer:

composer require ajangsupardi/laravel-postcode-my

The service provider is auto-discovered. No manual registration needed.

Publish Assets

Configuration (optional)

php artisan vendor:publish --tag=postcode-config

This creates config/postcode.php in your project root.

Migrations (optional)

php artisan vendor:publish --tag=postcode-migrations

Migrations are automatically loaded by the service provider. Publishing is only needed if you want to customize the table structure.

Database Setup

Run migrations to create the required tables:

php artisan migrate

This creates 3 tables:

Table Description
states 16 Malaysian states & territories
postcodes Postcode areas with post offices
locations Specific locations/streets with postcodes

Seed Database

Make sure you have run php artisan migrate first to create the required tables.

Run the seeder to populate your database:

php artisan postcode:seed

Or add to your DatabaseSeeder.php:

<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Ajangsupardi\PostcodeMy\Database\Seeders\PostcodeSeeder;

class DatabaseSeeder extends Seeder
{
    public function run(): void
    {
        $this->call([
            PostcodeSeeder::class,
        ]);
    }
}

That’s it! Your database is now populated with all Malaysian postcode data.

Update Data (Optional)

If you need the latest postcode data from Pos Malaysia:

php artisan postcode:download
php artisan postcode:seed

The download command queries the Pos Malaysia API for each postcode (00000–99999). This takes approximately 30 minutes.

After updating, bump the data version in config/postcode.php:

'data_version' => '1.1.0',
'data_updated_at' => '2026-12-31',

What’s Next?