sportscar03/psgc-database

(Customized) This is a simple CLI tool to easily add Philippine Standard Geographic Code (PSGC) data to your database.

dev-main 2025-08-18 07:01 UTC

README

A Laravel package to import the Philippine Standard Geographic Code (PSGC) into your database with optimized structure for regions, provinces, cities/municipalities, and barangays.

Installation

You can install the package via composer:

composer require sportscar03/psgc-database:dev-main

You can publish the config file with:

php artisan vendor:publish --tag="psgc-database-config"

This will create a config file:

<?php
return [
    'source' => public_path('psgc/latest.xlsx'),
];

Usage

Step 1: Publish and run the migrations

php artisan vendor:publish --tag="psgc-database-migrations"
php artisan migrate

Step 2: Download the latest PSGC data

php artisan psgc-db:download

This will download the latest PSGC Excel file and save it to your storage/public directory.

Step 3: Convert the Excel file into tables

php artisan psgc-db:convert

This will parse the Excel file and insert the data into the following tables:

  • regions
  • provinces
  • cities
  • barangays

License

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