Simple REST API implemented using Laravel Lumen. A project inspired from hyubs/ph-locations by Hyubs.
Provides a library of locations in the Philippines (regions, provinces, and cities/municipalities) that can automatically check the source, ensuring the data is always updated
PHP 7.3 and later.
- Run
git clone https://github.com/ikmespinoza/lumen-ph-geography.git
. - Create a MySQL database for the project:
mysql -u root -p
, if using Vagrant:mysql -u <username> -p <password>
create database <database-name>;
\q
- From the projects root run
cp .env.example .env
. - Configure your
.env
file. - Run
composer update
from the projects root folder. - From the projects root folder run
composer dump-autoload
. - From the projects root folder run
php artisan db:seed
.
+------+----------------------------------------------------------+--------------------------------+-----------------------------------------+---------+------------+
| Verb | Path | NamedRoute | Controller | Action | Middleware |
+------+----------------------------------------------------------+--------------------------------+-----------------------------------------+---------+------------+
| GET | /api/regions | regions.index | App\Http\Controllers\RegionController | index | |
| GET | /api/regions/{region} | regions.show | App\Http\Controllers\RegionController | show | |
| GET | /api/regions/{region}/provinces | regions.provinces.index | App\Http\Controllers\ProvinceController | index | |
| GET | /api/regions/{region}/provinces/{province} | regions.provinces.show | App\Http\Controllers\ProvinceController | show | |
| GET | /api/regions/{region}/provinces/{province}/cities | regions.provinces.cities.index | App\Http\Controllers\CityController | index | |
| GET | /api/regions/{region}/provinces/{province}/cities/{city} | regions.provinces.cities.show | App\Http\Controllers\CityController | show | |
+------+----------------------------------------------------------+--------------------------------+-----------------------------------------+---------+------------+
Property | Description | ISO 3166 |
---|---|---|
code | ISO 3166 | ✓ |
name | English name | ✓ |
name_tl | Tagalog name | ✓ |
acronym | Acronym, often the roman number or acronym of the region | ✓ |
provinces | Provinces in the region | ✓ |
ISO 3166
{
"code": "PH-13",
"name": "Caraga",
"name_tl": "Rehiyon ng Karaga",
"acronym": "XIII",
"provinces": [
{
"code": "PH-AGN",
"name": "Agusan del Norte",
"alt_name": null,
"name_tl": "Hilagang Agusan",
},
{
"code": "PH-AGS",
"name": "Agusan del Sur",
"alt_name": null,
"name_tl": "Timog Agusan",
},
{
"code": "PH-DIN",
"name": "Dinagat Islands",
"alt_name": null,
"name_tl": "Pulo ng Dinagat"
},
...
]
}
Property | Description | ISO 3166 |
---|---|---|
code | ISO 3166 | ✓ |
name | English name | ✓ |
alt_name | Alternative name, often its former name | ✓ |
name_tl | Tagalog name | ✓ |
region | ISO 3166 of the province's region | ✓ |
cities | Cities/Municipalities in the province | ✓ |
ISO 3166
{
"code": "PH-AGN",
"name": "Agusan del Norte",
"alt_name": null,
"name_tl": "Hilagang Agusan",
"region": {
"code": "PH-13",
"name": "Caraga",
"name_tl": "Rehiyon ng Karaga",
"acronym": "XIII"
},
"cities": [
{
"name": "Buenavista",
"alt_name": null,
"full_name": "Buenavista",
"is_capital": false,
"classification": {
"code": "Mun",
"description": "Municipality"
}
},
{
"name": "Butuan",
"alt_name": null,
"full_name": "Butuan City",
"is_capital": false,
"classification": {
"code": "HUC",
"description": "Highly Urbanized City"
}
},
{
"name": "Cabadbaran",
"alt_name": null,
"full_name": "Cabadbaran City",
"is_capital": true,
"classification": {
"code": "CC",
"description": "Component City"
}
},
...
}
Property | Description | ISO 3166 |
---|---|---|
name | Name | ✓ |
alt_name | Alternative name, often its former name | ✓ |
full_name | Complete name. For ISO 3166, all cities will have names end with "City". | ✓ |
is_capital | Is the city or municipality the capital of the province | ✓ |
classification | Classification of the city or municipality (see below) | ✓ |
province | ISO 3166 of the city's or municipality's province | ✓ |
ISO 3166
{
"name": "Bislig",
"alt_name": null,
"full_name": "Bislig City",
"is_capital": false,
"classification": {
"code": "CC",
"description": "Component City"
},
"province": {
"code": "PH-SUR",
"name": "Surigao del Sur",
"alt_name": null,
"name_tl": "Timog Surigaw"
}
}
ISO 3166
Value | Description |
---|---|
Mun | Municipality |
CC | Component city |
ICC | Independent component city |
HUC | Highly urbanized city |
Licensed under the MIT License.