定制 speelpenning/laravel-postcode-nl 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

speelpenning/laravel-postcode-nl

Composer 安装命令:

composer require speelpenning/laravel-postcode-nl

包简介

A Laravel client using the Postcode.eu REST API for Dutch address verification.

README 文档

README

Build Status Latest stable Version License

A client using the Postcode.eu REST API for Dutch address verification.

Installation

Pull the package in through Composer:

composer require speelpenning/laravel-postcode-nl

Next, register an account with Postcode.eu to obtain a key and secret, required to authenticate with the API. See https://account.postcode.eu/register/api/en_GB for more information. Once you have a key and secret, store them in your .env file.

Add the following service provider to your application config:

Speelpenning\PostcodeNl\PostcodeNlServiceProvider::class,

Walk through the configuration section to make things work.

Usage

There are two ways to use the address lookup: by injecting the address lookup service in your code or using the AddressController that is shipped with the package.

Dependency injection

Example:

<?php

use Exception;
use Speelpenning\PostcodeNl\Services\AddressLookup;

class AddressDumper {

    /**
     * @var AddressLookup
     */
    protected $lookup;
    
    /**
     * Create an address dumper instance.
     *
     * @param AddressLookup $lookup
     */
    public function __construct(AddressLookup $lookup)
    {
        $this->lookup = $lookup;
    }
    
    /**
     * Dumps the address details on screen.
     *
     * @param string $postcode
     * @param int $houseNumber
     * @param null|string $houseNumberAddition
     */
    public function dump($postcode, $houseNumber, $houseNumberAddition = null)
    {
        try {
            $address = $this->lookup->lookup($postcode, $houseNumber, $houseNumberAddition);
            dd($address);
        }
        catch (Exception $e) {
            exit('Ow, that went wrong...');
        }
    }

}

Using the JSON API

In order to use the API, enabled it in the configuration. When enabled, the following route is available:

route('postcode-nl::address', [$postcode, $houseNumber, $houseNumberAddition = null]);

or use the following URL (e.g. for AJAX calls):

/postcode-nl/address/{postcode}/{houseNumber}/{houseNumberAddition?}

Configuration

Credentials (required)

The key and secret are used for authentication. Without them, you cannot use the service.

POSTCODENL_KEY=<your-api-key>
POSTCODENL_SECRET=<your-secret>

Enable routes (optional)

This package comes with a ready to use JSON API, which is disabled by default. You can enable it like so:

POSTCODENL_ENABLE_ROUTES=true

Timeout (in seconds, optional)

By default, the client waits 10 seconds for a response. You may set a different timeout.

POSTCODENL_TIMEOUT=<timeout-in-seconds>

speelpenning/laravel-postcode-nl 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 21.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 34
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-14