承接 bkintanar/psgc-api-wrapper 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bkintanar/psgc-api-wrapper

Composer 安装命令:

composer require bkintanar/psgc-api-wrapper

包简介

PHP Wrapper for Philippine Standard Geographic Code API

README 文档

README

Overview

This package is a simple php wrapper for the PSGC API found here: https://github.com/bkintanar/psgc-api.

Installation

The recommended way to install PSGC API Wrapper is with Composer. Composer is a dependency management tool for PHP that allows you to declare the dependencies your project needs and installs them into your project.

# Install Composer
curl -sS https://getcomposer.org/installer | php

You can add PSGC API Wrapper as a dependency using Composer:

composer require bkintanar/psgc-api-wrapper

Alternatively, you can specify PSGC API Wrapper as a dependency in your project's existing composer.json file:

{
   "require": {
      "bkintanar/psgc-api-wrapper": "*"
   }
}

Supported Methods

All endpoints provided by https://github.com/bkintanar/psgc-api are supported.

+----------+------------------------------------------+
| Method   | URI                                      |
+----------+------------------------------------------+
| GET|HEAD | api/barangays                            |
| GET|HEAD | api/barangays/{barangay}                 |
| GET|HEAD | api/cities                               |
| GET|HEAD | api/cities/{city}                        |
| GET|HEAD | api/districts                            |
| GET|HEAD | api/districts/{district}                 |
| GET|HEAD | api/municipalities                       |
| GET|HEAD | api/municipalities/{municipality}        |
| GET|HEAD | api/provinces                            |
| GET|HEAD | api/provinces/{province}                 |
| GET|HEAD | api/regions                              |
| GET|HEAD | api/regions/{region}                     |
| GET|HEAD | api/sub-municipalities                   |
| GET|HEAD | api/sub-municipalities/{subMunicipality} |
+----------+------------------------------------------+

Using Laravel

Region

Region is the highest geographic level used by The Republic of the Philippines. The Philippines is divided into 17 regions as of 31 March 2020.

<?php

use PSGC\Facades\Region;

Region::get();                                                        // Get a Collection of regions
Region::find('070000000');                                            // Get a specific region
Region::includes('provinces')->get();                                 // Get a Collection of regions and provinces
Region::includes('districts')->get();                                 // Get a Collection of regions and districts
Region::includes(['provinces', 'districts'])->get();                  // Get a Collection of regions and provinces and districts

District

This geographic level is only used by the National Capital Region (NCR).

Unlike other administrative regions in the Philippines, Metro Manila is not composed of provinces. Instead, the region is divided into four geographic areas called "districts."

So instead of the usual geographic hierarchy of:

Region > Provinces > Cities, Municipalities > Barangays

The National Capital Region follows the geographic hierarchy of:

Region > Districts > Cities > Sub Municipalities > Barangays 
<?php

use PSGC\Facades\District;

District::get();                                                      // Get a Collection of districts
District::find('133900000');                                          // Get a specific district
District::includes('cities')->get();                                  // Get a Collection of districts with its collection of cities
District::includes('cities')->find('133900000');                      // Get a specific district with its collection of cities

Province

One or more provinces belongs to one region. The Philippines is administratively divided into 81 provinces as of 31 March 2020. Any given province has one or more cities, and municipalities under it.

<?php

use PSGC\Facades\Province;

Province::get();                                                      // Get a Collection of provinces
Province::find('072200000');                                          // Get a specific province
Province::includes('cities')->get();                                  // Get a Collection of provinces with its collection of cities
Province::includes('cities')->find('072200000');                      // Get a specific province with its collection of cities
Province::includes('municipalities')->get();                          // Get a Collection of provinces with its collection of municipalities
Province::includes('municipalities')->find('072200000');              // Get a specific province with its collection of municipalities
Province::includes(['cities', 'municipalities'])->get();              // Get a Collection of provinces with its collection of cities and municipalities
Province::includes(['cities', 'municipalities'])->find('072200000');  // Get a specific province with its collection of cities and municipalities

City

One or more cities belongs to one province or district. The Philippines is administratively divided into 146 cities as of 31 March 2020. Any given city has one or more barangays, sub-municipalities under it.

<?php

use PSGC\Facades\City;

City::get();                                                          // Get a Collection of cities
City::find('072217000');                                              // Get a specific city
City::includes('barangays')->get();                                   // Get a Collection of cities with its collection of barangays. Not advised as this will retrieve all 42,046 barangays.
City::includes('barangays')->find('072217000');                       // Get a specific city with its collection of barangays
City::includes('subMunicipalities')->find('133900000');               // Get a specific city with its collection of sub-municipalities

Municipality

One or more municipalities belongs to one Province. The Philippines is administratively divided into 1,488 municipalities as of 31 March 2020. Any given municipality has one or more barangays under it.

<?php

use PSGC\Facades\Municipality;

Municipality::get();                                                  // Get a Collection of municipalities
Municipality::find('072201000');                                      // Get a specific municipality
Municipality::includes('barangays')->get();                           // Get a Collection of municipalities with its collection of barangays.
Municipality::includes('barangays')->find('072201000');               // Get a specific municipality with its collection of barangays

Sub Municipality

This geographic level is only used by the National Capital Region (NCR).

As far as NCR is concerned, cities have one or more sub-municipalities and each sub-municipality has one or more barangays.

<?php

use PSGC\Facades\SubMunicipality;

SubMunicipality::get();                                               // Get a Collection of sub-municipalities
SubMunicipality::find('133901000');                                   // Get a specific sub-municipality
SubMunicipality::includes('barangays')->get();                        // Get a Collection of sub-municipalities with its collection of barangays.
SubMunicipality::includes('barangays')->find('133901000');            // Get a specific sub-municipality with its collection of barangays

Barangay

This is the lowest geographic level used by The Philippines. Any given barangay may be under to one city, one municipality, one sub-municipality. As barangay's the lowest geographic level, it doesn't have any geographic level under it, so no valid includes.

<?php

use PSGC\Facades\Barangay;

Barangay::get();                                                      // Get a Collection of barangays. advised as this will retrieve all 42,046 barangays.
Barangay::find('072201001');                                          // Get a specific sub-municipality

Using Vanilla PHP

<?php

require('vendor/autoload.php');

use PSGC\Region;

$region = new Region();

$region->get();                                                       // Get a Collection of regions
$region->find('070000000');                                           // Get a specific region
$region->includes('provinces')->get();                                // Get a Collection of regions and provinces
$region->includes('districts')->get();                                // Get a Collection of regions and districts
$region->includes(['provinces', 'districts'])->get();                 // Get a Collection of regions and provinces and districts

Follow the pattern above to use with other geographic levels.

bkintanar/psgc-api-wrapper 适用场景与选型建议

bkintanar/psgc-api-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.9k 次下载、GitHub Stars 达 46, 最近一次更新时间为 2020 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 bkintanar/psgc-api-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 bkintanar/psgc-api-wrapper 我们能提供哪些服务?
定制开发 / 二次开发

基于 bkintanar/psgc-api-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8.9k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 46
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 46
  • Watchers: 4
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-08-26