承接 jord-jd/php-postcodes 相关项目开发

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

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

jord-jd/php-postcodes

最新稳定版本:v5.0.0

Composer 安装命令:

composer require jord-jd/php-postcodes

包简介

This library handles various UK postcode related tasks such as address lookup by postcode, postcode validation, generation of valid UK postcodes and getting a postcode's outward and inward codes.

README 文档

README

Build Status Coverage Status StyleCI Packagist

This library handles various UK postcode related tasks.

Features

  • Address lookup by postcode
  • Postcode validation
  • Generate valid UK postcodes
  • Get a postcode's outward and inward codes

Installation

To install, just run the following composer command.

composer require jord-jd/php-postcodes

Setup

Postcode Lookup Services

Using some of the data retrieval features provided by this library requires a postcode lookup service. It currently supports the following postcode lookup services.

Sign up at the respective website if you need to use these features.

You can then use the following code to get an appropriate postcode lookup service object.

$postcodeLookupService = new \JordJD\Postcodes\Objects\IdealPostcodes('API_KEY');
// OR
$postcodeLookupService = new \JordJD\Postcodes\Objects\PostcodeAnywhere('API_KEY');
// OR
$postcodeLookupService = new \JordJD\Postcodes\Objects\PostcodesIo();

Usage

Get addresses by postcode

To retrieve the addresses associated with a UK postcode, just pass it to the method shown below. You will receive an array of address objects, appropriately split by their address lines and other details.

$addresses = $postcodeLookupService->getAddressesByPostcode('ST163DP');

Validate postcode

You can validate a UK postcode is correct using the Validator utility class. An example of how to do so is shown below.

$validated = \JordJD\Postcodes\Utils\Validator::validatePostcode('ST163DP');

Please note that the postcode validation is case insensitive.

Generate postcode

This library allows you generate a random, valid UK postcode. This makes use of the Generator utility class, as shown below.

$postcode = \JordJD\Postcodes\Utils\Generator::generatePostcode();

Get outward and inward codes

The first part of the Postcode eg PO1 is called the outward code as it identifies the town or district to which the letter is to be sent for further sorting. The second part of the postcode eg 1EB is called the inward code.

$outwardCode = \JordJD\Postcodes\Utils\Tokenizer::outward('ST163DP'); // Returns ST16
$inwardCode = \JordJD\Postcodes\Utils\Tokenizer::inward('ST163DP'); // Returns 3DP

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 6
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-only
  • 更新时间: 2026-02-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固