jaydoesphp/psgc-php

There is no license information available for the latest version (v1.0.3) of this package.

A PHP package for retrieving and managing Philippine Standard Geographic Code (PSGC) data, including regions, provinces, cities, and barangays.

v1.0.3 2025-07-16 15:08 UTC

This package is auto-updated.

Last update: 2025-07-16 15:09:44 UTC


README

PSGC-PHP is a PHP package for handling Philippine Standard Geographic Code (PSGC) data. It provides tools to retrieve and search geographic information such as regions, provinces, cities, municipalities, and barangays from JSON files.

Features

  • Access PSGC data from JSON files.
  • Search address records using PSGC codes.
  • Organized helper classes for file and lookup handling.
  • Includes unit tests for each geographic level.

Installation

composer require jaydoesphp/psgc-php

Get All Methods

Address Type Method Description
Region getRegions() Get all regions.
Province getProvinces() Get all provinces.
City getCities() Get all cities.
Barangay getBarangays() Get all barangays.

Get All By Code Methods

Address Type Method Description
Province getAllProvincesByRegionCode($region_code) Provinces under a specific region.
City getAllCitiesByProvinceCode($province_code) Cities under a specific province.
Barangay getAllBarangaysByCityCode($city_code) Barangays under a specific city.

Get By Code Methods

Address Type Method Description
Region getRegionsByCode($region_code) Get a region by code.
Province getProvincesByCode($province_code) Get a province by code.
City getCitiesByCode($city_code) Get a city by code.
Barangay getBarangaysByCode($barangay_code) Get a barangay by code.

Usage Examples

Get All Provinces

use Jaydoesphp\PSGCphp\PSGC;

$provinces = PSGC::getProvinces();
print_r($provinces);

Get All Cities by Province Code

use Jaydoesphp\PSGCphp\PSGC;

$cities = PSGC::getAllCitiesByProvinceCode('0128');
print_r($cities);

Get a Specific Barangay by Code

use Jaydoesphp\PSGCphp\PSGC;

$barangay = PSGC::getBarangaysByCode('012801001');
print_r($barangay);

File Structure

  • src/ - Core PHP logic.
  • src/resources/json/ - PSGC JSON data.
  • tests/ - PHPUnit tests.

Run Tests

vendor/bin/phpunit

License

MIT License.