freshheads/postcode-api-client
最新稳定版本:4.1.1
Composer 安装命令:
composer require freshheads/postcode-api-client
包简介
Client library for the postcodeapi.nu web service.
README 文档
README
FHPostcodeAPIClient is a PHP client library for the PostcodeAPI.nu web service. This library is developed by Freshheads and will be maintained in sync with the web service itself.
Links:
Installation
FHPostcodeAPIClient can easily be installed using Composer:
composer require freshheads/postcode-api-client
Usage
Instantiate the client and replace the API key with your personal credentials:
// Use the composer autoloader to load dependencies require_once 'vendor/autoload.php'; // initiate client $apiKey = 'replace_with_your_own_api_key'; // In this example we made use of the Guzzle as HTTPClient. $client = new \FH\PostcodeAPI\Client( new GuzzleHttp\Client([ 'headers' => [ 'X-Api-Key' => $apiKey ] ]) ); // call endpoints $response = $client->getAddresses('5041EB', 21); $response = $client->getAddress('0855200000061001'); $response = $client->getPostcodeDataByPostcode('5041EB'); // Note that this call is only available with a premium account $response = $client->getPostcodes('51.566405', '5.077171');
Within a Symfony project
We recommend to use Guzzle, to be able to use Guzzle in combination with the PostcodeApiClient. Following definition is used with an implementation of Guzzle 7.
_defaults: autowire: true autoconfigure: true project.http.client.postal_code: class: GuzzleHttp\Client bind: $config: { headers: { X-Api-Key: '%postcode_api_nu.key%' } } FH\PostcodeAPI\Client: $httpClient: '@project.http.client.postal_code'
You should now be able use the FH\PostcodeAPI\Client service to make requests to the PostcodeAPI.
Guzzle 6
To make use of Guzzle 6, you should also make use of the Guzzle6Adapter. By running the following command you automatically install Guzzle as well.
composer require php-http/guzzle6-adapter
And add the following service definitions (usable in Symfony ^3.4):
services: _defaults: autowire: true autoconfigure: true project.http.guzzle.client: class: GuzzleHttp\Client arguments: - { headers: { X-Api-Key: 'replace_with_your_own_api_key_or_variable' } } project.http.adapter.guzzle.client: class: Http\Adapter\Guzzle6\Client arguments: $client: '@project.http.guzzle.client' FH\PostcodeAPI\Client: $httpClient: '@project.http.adapter.guzzle.client'
freshheads/postcode-api-client 适用场景与选型建议
freshheads/postcode-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 123.77k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「client」 「postcode」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 freshheads/postcode-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 freshheads/postcode-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 freshheads/postcode-api-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Spikkl API client library for PHP
Symfony Bundle for commonground balance functionality
A PSR-7 compatible library for making CRUD API endpoints
Validates Zip/Postal Codes for any country and provides each country's localized name for their version of the Zip/Postal code (CEP, PLZ, PIN code, Eircode, NPA, CAP, ZIP code, etc.).
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
统计信息
- 总下载量: 123.77k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04