Download the PHP package pralhadstha/zipcoder-php without Composer

On this page you can find all versions of the php package pralhadstha/zipcoder-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package zipcoder-php

Zipcoder

A PHP library to convert postal codes and zip codes into structured addresses using multiple geocoding APIs with automatic fallback.

Latest Version on Packagist PHP Version Total Downloads PHPStan Level 9 Tests


Zipcoder turns any postal code into a normalized address (city, state, province, country, and coordinates) by querying postal code lookup APIs behind a unified interface. If one provider fails or has no data, the next one in the chain picks up automatically. No more vendor lock-in to a single zip code API.

Use cases: shipping & logistics address autofill, checkout form validation, postal code to city/state resolution, international address lookup, and geocoding from zip codes.

Key Features

Supported Providers

Provider Countries Auth Required Free Tier Best For
GeoNames 100+ Free username 10,000/day Primary global provider
Zippopotamus ~60 None Unlimited Quick lookups, zero config
Zipcodestack 210+ API key 300/month Broadest country coverage
Zipcodebase 100+ API key 10,000/month Good middle-ground
JpPostalCode Japan None Unlimited Japan addresses in EN/JA/Kana

Requirements

Installation

For production, Guzzle is recommended as the HTTP client:

Framework Integration

If you are using a framework, check out our dedicated integration package:

Framework Package Stats
Laravel pralhadstha/zipcoder-laravel Latest Stable Version Total Downloads

Quick Start

Look up a US zip code and get the city and state in 4 lines:

With Guzzle

With Automatic Fallback (Chain)

Usage

Creating Queries

A Query represents a postal code lookup request. It validates input and normalizes the postal code:

Working with Results

Every provider returns an AddressCollection containing normalized Address objects:

Providers

GeoNames — 100+ countries, free username registration Returns: `postalCode`, `countryCode`, `city`, `state`, `stateCode`, `province`, `latitude`, `longitude`
Zippopotamus — ~60 countries, no authentication needed Returns: `postalCode`, `countryCode`, `countryName`, `city`, `state`, `stateCode`, `latitude`, `longitude`
Zipcodestack — 210+ countries, broadest coverage Returns: `postalCode`, `countryCode`, `city`, `state`, `province`, `latitude`, `longitude`
Zipcodebase — 100+ countries, 10k requests/month free Returns: `postalCode`, `countryCode`, `city`, `state`, `stateCode`, `province`, `latitude`, `longitude`
JpPostalCode — Japan-only, free, supports English/Japanese/Kana Returns: `postalCode`, `countryCode` (JP), `countryName` (Japan), `state`, `stateCode`, `city`, `district` > Automatically skips non-JP queries in a chain — no API call is made.

Chain Provider (Automatic Fallback)

The Chain provider implements the Chain of Responsibility pattern. It tries each provider in order and returns the first successful result. If a provider throws an error or returns no data, it moves to the next one.

How fallback works:

  1. Each provider is tried in the order given
  2. If a provider returns addresses, that result is returned immediately
  3. If a provider throws NoResult or HttpError, the chain logs a warning and continues
  4. If a provider returns an empty collection, the chain skips to the next
  5. InvalidArgument exceptions (programming errors) are not caught — they bubble up
  6. If all providers fail, a NoResult exception is thrown

Cache Provider (PSR-16)

The Cache decorator wraps any provider with PSR-16 caching to avoid redundant API calls:

Cache key format: zipcoder:{COUNTRY_CODE}:{NORMALIZED_CODE} (e.g., zipcoder:US:90210, zipcoder:JP:1000014)

ZipcoderLookup (Provider Registry)

ZipcoderLookup is a convenience aggregator to register and access providers by name:

Full Production Example

Creating a Custom Provider

Implement the Provider interface or extend AbstractHttpProvider to integrate any postal code API:

Then add it to your chain:

Error Handling

Zipcoder uses a clear exception hierarchy:

Exception When Caught by Chain?
NoResult No address found for the postal code Yes (falls back)
HttpError Network failure or HTTP error Yes (falls back)
ProviderNotRegistered Unknown provider name in ZipcoderLookup::using() No
InvalidArgument Invalid input (empty postal code, bad country code) No (programming error)

HTTP Client Options

Zipcoder accepts any PSR-18 compatible HTTP client. The first constructor argument is the ClientInterface, the second is the RequestFactoryInterface. Many clients (Guzzle 7, the included curl client) implement both.

Client Install Example
Built-in curl Included new CurlPsr18Client(timeout: 10)
Guzzle 7 composer require guzzlehttp/guzzle new \GuzzleHttp\Client(['timeout' => 10])
Symfony HttpClient composer require symfony/http-client PSR-18 adapter

Testing

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-provider)
  3. Write tests for any new functionality
  4. Ensure all tests pass (vendor/bin/phpunit)
  5. Run static analysis (vendor/bin/phpstan analyse)
  6. Format your code (vendor/bin/pint)
  7. Submit a pull request

License

Zipcoder is open-sourced software licensed under the MIT License.

Copyright (c) 2026 Pralhad Kumar Shrestha


All versions of zipcoder-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/simple-cache Version ^3.0
psr/log Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pralhadstha/zipcoder-php contains the following files

Loading the files please wait ...