Search by

baspa / zip-code-location-lookup

Baspa

y

Package info

github.com/Baspa/zip-code-location-lookup

Homepage

pkg:composer/baspa/zip-code-location-lookup

Fund package maintenance!

baspa

Statistics

Installs: 46

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v0.4.0 2026-11-19 09:42 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This package looks up the street, city and coordinates of a Dutch zip code and house number with the Google Geocoding API. When geocoding only finds the postcode area, it falls back to the Google Places API and reverse geocoding to find the street.

Requirements

  • PHP 8.3 or higher
  • Laravel 13

On Laravel 9 to 12 or PHP 8.1 and 8.2, use version 0.2 of this package:

composer require baspa/zip-code-location-lookup:^0.2

Installation

You can install the package via composer:

composer require baspa/zip-code-location-lookup

Then add your Google Maps API key to your .env file. The key needs the Geocoding API; with the Places API also enabled, lookups that only match a postcode area find the street more often.

GOOGLE_MAPS_API_KEY=your_api_key

And add it to the services.php config file:

return [

    // ...

    'google' => [
        'api_key' => env('GOOGLE_MAPS_API_KEY'),
    ],
];

Usage

use Baspa\ZipCodeLocationLookup\ZipCodeLocationLookup;

$result = (new ZipCodeLocationLookup())->lookup(zipCode: '1012JS', number: 1);

// [
//     'street' => 'Dam',
//     'houseNumber' => 1,
//     'postcode' => '1012JS',
//     'city' => 'Amsterdam',
//     'municipality' => 'Amsterdam',
//     'province' => 'Noord-Holland',
//     'country' => 'NLD',
//     'lat' => 52.373169,
//     'lng' => 4.893379,
// ]

lookup() throws an InvalidArgumentException when the zip code can't be geocoded, and the constructor throws one when the Google Maps API key is missing.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.