PSGC-PHP is a PHP package designed to handle Philippine Standard Geographic Code (PSGC) data. It provides utilities for searching and retrieving geographic information such as regions, provinces, cities, municipalities, sub-municipalities, and barangays from JSON datasets.
- Retrieve Philippine geographic data from JSON files.
- Search addresses by PSGC code.
- Helper functions for handling content retrieval.
- Unit tests for each geographic level.
To install PSGC-PHP, use Composer:
composer require jaydoesphp/psgc-php
Address Type | Method Name | Description |
---|---|---|
Region | getRegions() |
Retrieves all regions in the Philippines. |
Province | getProvinces() |
Retrieves all provinces within a specified region. |
City/Municipality | getCitiesMunicipalities() |
Retrieves all cities and municipalities within a specified province. |
Municipality | getMunicipalities() |
Retrieves all municipalities within a province. |
City | getCities() |
Retrieves all cities within a province. |
Sub-Municipality | getSubMunicipalities() |
Retrieves all sub-municipalities. |
Barangay | getBarangays() |
Retrieves all barangays within a city or municipality. |
Search Type | Method Name | Description |
---|---|---|
Region | searchRegionByCode($code) |
Finds a region using its PSGC code. |
Province | searchProvinceByCode($code) |
Finds a province using its PSGC code. |
City/Municipality | searchCitiesMunicipalityByCode($code) |
Finds a city/municipality using its PSGC code. |
Municipality | searchMunicipalityByCode($code) |
Finds a municipality using its PSGC code. |
City | searchCityByCode($code) |
Finds a city using its PSGC code. |
Sub-Municipality | searchSubMunicipalityByCode($code) |
Finds a sub-municipality using its PSGC code. |
Barangay | searchBarangayByCode($code) |
Finds a barangay using its PSGC code. |
// …
use Jaydoesphp\PSGCphp\PSGC;
$provinces = PSGC::getProvinces();
print_r($provinces);
// …
use Jaydoesphp\PSGCphp\PSGC;
$province = PSGC::searchProvinceByCode('0102800000');
print_r($province);
src/
- Contains the core PHP classes and helpers.src/resources/json/
- Stores PSGC data in JSON format.tests/
- Unit tests for validation.
To run unit tests, execute:
vendor/bin/phpunit
This project is licensed under the MIT License.