承接 schoolees/laravel-psgc 相关项目开发

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

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

schoolees/laravel-psgc

Composer 安装命令:

composer require schoolees/laravel-psgc

包简介

PSGC for Laravel: migrations, seeders, JSON data, models, services, resources, controllers, and read-only routes.

README 文档

README

Latest Stable Version Total Downloads License

A Laravel package for handling Philippine Standard Geographic Code (PSGC) data — including Regions, Provinces, Cities/Municipalities, and Barangays.

It comes complete with migrations, seeders, JSON data, Eloquent models, services, controllers, API resources, and routes following clean Laravel architecture.

📦 Features

  • Full PSGC database structure (Regions, Provinces, Cities, Barangays)
  • JSON PSGC dataset in resources/psgc/
  • Database migrations and seeders for an initial data load
  • Eloquent models with relationships and searchable fields
  • Service layer for clean business logic
  • REST API controllers & resources
  • Artisan command to regenerate PSGC models
  • Ready-to-use API routes for all PSGC endpoints

📋 Requirements

  • PHP >= 8.1
  • Laravel 10.x to 13.x
  • Laravel 13 requires PHP 8.3+ (per Laravel's support policy)
  • MySQL / MariaDB

🤝 Contributing

Repository development/testing notes are in CONTRIBUTING.md.

⚙️ Installation

Require the package via Composer:

composer require schoolees/laravel-psgc

Quick installation:

php artisan psgc:install --seed
php artisan psgc:install --force --seed # Overwrite previously published package files

By default, the package auto-registers routes at /{PSGC_API_PREFIX} and keeps the same URL shape if you later switch to published routes.

Publishing assets (optional):

# Config
php artisan vendor:publish --tag=psgc-config

# Seeders
php artisan vendor:publish --tag=psgc-seeders

# Routes
php artisan psgc:publish-routes
php artisan psgc:publish-routes --force # Overwrite if re-running

# Resources
php artisan vendor:publish --tag=psgc-resources
php artisan vendor:publish --tag=psgc-resources-classes

Generate PSGC models (optional):

php artisan make:psgc-models
php artisan make:psgc-models --force # Overwrite existing models
php artisan make:psgc-models --softdeletes # Include SoftDeletes trait

Example Request:

# Get all Regions
GET /psgc/regions

# Get Cities in the National Capital Region (NCR)
GET /psgc/cities?region_code=1300000000

# Get the City of Manila
GET /psgc/cities?code=1380600000

# Get Barangays in the City of Manila
GET /psgc/barangays?city_code=1380600000

Example JSON Response:

{
  "code": 200,
  "draw": 1,
  "recordsFiltered": 1,
  "recordsTotal": 1,
  "recordsPerPage": 10,
  "data": [
    {
      "code": "1380600000",
      "name": "City of Manila",
      "province_code": null,
      "region_code": "1300000000"
    }
  ],
  "filters": {
    "code": "1380600000"
  }
}

Filtering and Searching

You can filter results by passing query parameters. Refer to the getSearchable() method on each model for available filterable fields.

Example: Get cities in the National Capital Region (NCR)

GET /psgc/cities?region_code=1300000000

Example: Search for a city by name

GET /psgc/cities?name=Manila

🔍 Searchable Fields

Each model has a getSearchable() method to define searchable columns for filtering via API.

Example for a City model:

public function getSearchable(): array
{
    return [
        'query' => ['code', 'region_code', 'province_code', 'is_city'],
        'query_like' => ['name', 'city_class'],
    ];
}

🧩 Service Layer

The package follows the Service-Controller-Resource pattern for clean, maintainable code.

Example:

$results = $this->cityService->getCities(
    request()->all(),
    request()->input('order_by', 'name'),
    request()->input('sort_by', 'desc'),
    request()->input('limit', 10),
    request()->input('offset', 0)
);

Optional .env overrides

To customize API prefix:

PSGC_API_PREFIX=geo # Will change /psgc/regions to /geo/regions.

Route strategy (important):

  • Default: package auto-registers routes via service provider.
  • Published routes are appended to routes/web.php with the configured PSGC prefix and middleware so they keep the same /{prefix}/* URLs.
  • If you want to use published routes/psgc.php, disable package route registration to avoid duplicates:
// config/psgc.php
'register_package_routes' => false,

Pagination safety override:

// config/psgc.php
'max_limit' => 100, // caps ?limit=...

Response format override:

// config/psgc.php
'response_format' => 'datatable', // or 'pagination'

📜 License

This package is open-sourced software licensed under the MIT license.

🏢 About

Developed & maintained by Schoolees as part of the Schoolees Educational Suite.

📊 Data Source

This package uses the official Philippine Standard Geographic Code (PSGC) dataset published by the Philippine Statistics Authority (PSA).

Latest Dataset Used: 📄 PSGC 2Q 2025 Publication Datafile (Excel)

Attribution: Philippine Statistics Authority — Philippine Standard Geographic Code (PSGC)

Update Frequency: Quarterly (based on PSA publication schedule)

schoolees/laravel-psgc 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-09