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.
- 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.
composer require arxjei/psgc-php
Address Type | Method | Description |
---|---|---|
Region | getRegions() | Get all regions. |
Province | getProvinces() | Get all provinces. |
City | getCities() | Get all cities. |
Barangay | getBarangays() | Get all barangays. |
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. |
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. |
use Arxjei\PSGC;
$provinces = PSGC::getProvinces();
print_r($provinces);
use Arxjei\PSGC;
$cities = PSGC::getAllCitiesByProvinceCode('0128');
print_r($cities);
use Arxjei\PSGC;
$barangay = PSGC::getBarangaysByCode('012801001');
print_r($barangay);
src/
- Core PHP logic.src/resources/json/
- PSGC JSON data.tests/
- PHPUnit tests.
vendor/bin/phpunit
MIT License.