phdevutils / psgc-barangays
Complete PSGC barangay dataset for the Philippines (PSA Q4 2024, 42,046 entries) with zero-dependency lookup helpers. Joins to phdevutils/core cities/municipalities.
v0.1.0
2026-05-25 04:40 UTC
Requires
- php: >=8.2
Requires (Dev)
- phpunit/phpunit: ^10.0
README
The complete PSGC barangay dataset for the Philippines — 42,046 barangays (PSA Q4 2024) — with zero-dependency lookup helpers. Companion to phdevutils/core; every barangay's cityMunCode joins that package's cities/municipalities.
composer require phdevutils/psgc-barangays
API — PhDevUtils\PsgcBarangays\Barangays
Each barangay is an associative array:
[ 'code' => '012801001', // PSGC 9-digit 'name' => 'Adams (Pob.)', 'cityMunCode' => '012801',// 6-digit parent (joins phdevutils/core) 'province' => '0128', // 4-digit, or null for HUC/NCR 'region' => '01', // 2-digit ]
Barangays::list(array $filter = []): array
Filter keys: cityMunCode, province (pass null to match HUC/NCR), region.
Barangays::list(['cityMunCode' => '012801']); Barangays::list(['region' => '13']); // all NCR Barangays::list(['province' => null]); // HUC/NCR with no province
Barangays::find(string $code): ?array
Exact match by 9-digit PSGC code (names are not unique).
Barangays::find('012801001'); // ['code' => '012801001', 'name' => 'Adams (Pob.)', ...] Barangays::find('999999999'); // null
Barangays::findByName(string $name, array $filter = []): array
Case-insensitive. Always returns a list — names repeat heavily ("Poblacion" 605×, "San Isidro" 296×).
Barangays::findByName('San Isidro'); // 296 Barangays::findByName('San Isidro', ['region' => '13']); // 3
Barangays::count(array $filter = []): int
Barangays::count(); // 42046 Barangays::count(['region' => '13']); // 1710
License
MIT