2017 © Pedro PelĂĄez
 

library swiss-zip-code-resolver

A resolver for Swiss zip codes (PLZ).

image

onlime/swiss-zip-code-resolver

A resolver for Swiss zip codes (PLZ).

  • Tuesday, April 18, 2017
  • by onlime
  • Repository
  • 2 Watchers
  • 1 Stars
  • 38 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

:warning: This project was abondoned in favor of aternus/geonames-client which uses GeoNames data. I recommend using that project instead as it supports current international data and is very easy to use., (*1)

Onlime's Swiss Zip Code Resolver

Copyright (c) Onlime GmbH, https://www.onlime.ch, (*2)

A simple zip code lookup library to get information like city, commune, canton, and coordinates (LV03) for a Swiss zip code (PLZ)., (*3)

Installation

PHP versions 5.6 up to PHP 7.1 are currently supported., (*4)

The zip extension is required. PHP should be compiled with zip support by using the --enable-zip configure option., (*5)

It is recommended to use Composer to install the library., (*6)

$ composer require onlime/swiss-zip-code-resolver

You can also use any other PSR-4 compliant autoloader., (*7)

Usage

  • Create Resolver object
$Resolver = new Onlime\SwissZipCodeResolver\Resolver();
  • Call lookup() method
$Result = $Resolver->lookup($zipcode);
  • Sample of a Result object:
Onlime\SwissZipCodeResolver\Result Object
(
    [zipcode] => 8046
    [city] => ZĂŒrich
    [extraDigit] => 0
    [commune] => ZĂŒrich
    [bfsNr] => 261
    [canton] => ZH
    [east] => 680711
    [north] => 252925
    [validZipCode] => 1
)
  • You may choose from 5 different return types. The types are array, object, json, serialize and xml. By default it is object. If you want to change that call the format method before calling the parse method or provide the format to the constructor. If you are not using object and an error occurs, then exceptions will not be trapped within the response and thrown directly.
$Resolver->setFormat('json');
$Resolver = new Onlime\SwissZipCodeResolver\Resolver('json');
  • The Resolver supports the fluent interface on its setters, e.g.:
$Resolver = new Onlime\SwissZipCodeResolver\Resolver();
$Resolver
    ->setCachePath('/tmp')
    ->setCacheTime(86400)
    ->setFormat('json');
$json = $Resolver->lookup(8046);

Credits

The data is provided and updated by GEO.ADMIN.CH:, (*8)

Issues

Please report any issues via https://github.com/onlime/SwissZipCodeResolver/issues, (*9)

Copyright (c) 2007 - 2016 Onlime Webhosting (https://www.onlime.ch), (*10)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at, (*11)

http://www.apache.org/licenses/LICENSE-2.0, (*12)

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License., (*13)

The Versions

18/04 2017

dev-master

9999999-dev https://github.com/onlime/SwissZipCodeResolver

A resolver for Swiss zip codes (PLZ).

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0
  • ext-zip *

 

php postal code zipcode zip code swiss plz switzerland

18/04 2017

1.0.1

1.0.1.0 https://github.com/onlime/SwissZipCodeResolver

A resolver for Swiss zip codes (PLZ).

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0
  • ext-zip *

 

php postal code zipcode zip code swiss plz switzerland

27/11 2016

1.0.0

1.0.0.0 https://github.com/onlime/SwissZipCodeResolver

A resolver for Swiss zip codes (PLZ).

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0
  • ext-zip *

 

php postal code zipcode zip code swiss plz switzerland