galahad/laravel-addressing 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

galahad/laravel-addressing

Composer 安装命令:

composer require galahad/laravel-addressing

包简介

Laravel package providing addressing functionality

README 文档

README

Tests status MIT License Latest stable version

Laravel Addressing

Laravel Addressing is a Laravel package providing addressing functionality based on commerceguys/addressing. It lets you easily work with addresses using data from CLDR and Google.

The primary focus of Laravel Addressing is:

  • Access to up-to-date lists of countries, states/provinces, etc
  • Easily validate address data
  • Format addresses to match a specific country's rules

If you find this package useful, you should check out Franklin, our universal address input that follows the same conventions as Laravel Addressing.

Installation

First, install the composer package:

composer require galahad/laravel-addressing

Basic Usage

Country

$country = Addressing::country('US');
echo $country->getName(); // "United States"
echo $country->getCountryCode(); // "US"

Administrative Area (typically states or provinces)

$usa = Addressing::country('US');

echo $usa->administrativeArea('AL')->getName(); // "Alabama"
echo $usa->administrativeArea('AL')->getCode(); // "AL"

typeof $usa->administrativeAreas() // AdministrativeAreaCollection

Validators

You can use some custom validators in your Laravel app:

Countries

You can use country, country_code, or country_name to validate country input:

$this->validate($request, [
    'country' => 'required|country_code', // Must be a 2-letter ISO code, such as "US"
]);

$this->validate($request, [
    'country' => 'required|country_name', // Must be the full country name, such as "United States"
]);

$this->validate($request, [
    'country' => 'required|country', // Must be the full country name or 2-letter ISO code
]);

Administrative Areas

You can use administrative_area, administrative_area_code, or administrative_area_name to validate administrative area input:

// "country_field" is the form input that represents the country to validate against

$this->validate($request, [
    'state' => 'required|administrative_area_code:name_of_country_field',
]);

$this->validate($request, [
    'state' => 'required|administrative_area_name:country_field',
]);

$this->validate($request, [
    'state' => 'required|administrative_area:country_field',
]);

Postal Code

You can use postal_code to validate the zip/postal code:

$this->validate($request, [
    'postal_code' => 'required|postal_code:country_field,administrative_area_field',
]);

HTTP Endpoints

Laravel Addressing publishes two routes by default, which can be disabled in the config file. The prefix (/galahad/addressing) can also be configured.

GET /galahad/addressing/countries

{
    "label": "Countries",
    "options": {
        "AF": "Afghanistan",
        "..": "...",
        "ZW": "Zimbabwe"
    }
}

GET /galahad/addressing/countries/us/administrative-areas

{
     "label": "States",
     "country_code": "US",
     "options": {
        "AL": "Alabama",
        "**": "*******",
        "WY": "Wyoming"
     }
}

Thanks!

Special thanks to Commerce Guys for their amazing addressing and intl packages, which this project relies heavily on.

galahad/laravel-addressing 适用场景与选型建议

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

它主要适用于以下技术方向: 「address」 「validation」 「addressing」 「laravel」 「countries」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 333.57k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 70
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 69
  • Watchers: 3
  • Forks: 19
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-05