PHPackages                             marshmallow/laravel-nominatim - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. marshmallow/laravel-nominatim

ActiveLibrary[API Development](/categories/api)

marshmallow/laravel-nominatim
=============================

Laravel integration for Nominatim Geocoding API Client

070PHP

Since Feb 8Pushed 1y agoCompare

[ Source](https://github.com/marshmallow-forks/laravel-nominatim)[ Packagist](https://packagist.org/packages/marshmallow/laravel-nominatim)[ RSS](/packages/marshmallow-laravel-nominatim/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/9f3222e77445d6e6e9df0437136a6ab1e4040328befad134212ed45c768f158d/687474703a2f2f706f7365722e707567782e6f72672f77696d736b692f6c61726176656c2d6e6f6d696e6174696d2f76)](https://packagist.org/packages/wimski/laravel-nominatim)[![Coverage Status](https://camo.githubusercontent.com/1e0c1d50bec1398b4e2827f9c957b4b11215efb3d8c80d56382de080758e6d67/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f77696d736b692f6c61726176656c2d6e6f6d696e6174696d2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/wimski/laravel-nominatim?branch=master)[![PHPUnit](https://github.com/wimski/laravel-nominatim/actions/workflows/phpunit.yml/badge.svg)](https://github.com/wimski/laravel-nominatim/actions/workflows/phpunit.yml)[![PHPStan](https://github.com/wimski/laravel-nominatim/actions/workflows/phpstan.yml/badge.svg)](https://github.com/wimski/laravel-nominatim/actions/workflows/phpstan.yml)

Laravel integration for Nominatim Geocoding API Client
======================================================

[](#laravel-integration-for-nominatim-geocoding-api-client)

This package is a Laravel integration of the [Nominatim Geocoding API Client](https://packagist.org/packages/wimski/nominatim-geocoding-api-client).

Changelog
---------

[](#changelog)

[View the changelog.](./CHANGELOG.md)

Usage
-----

[](#usage)

### Install package

[](#install-package)

```
composer require wimski/laravel-nominatim
```

### Example

[](#example)

```
use Wimski\Nominatim\Contracts\GeocoderServiceInterface;
use Wimski\Nominatim\Objects\Coordinate;
use Wimski\Nominatim\RequestParameters\ForwardGeocodingQueryRequestParameters;

class MyClass
{
    public function __construct(
        protected GeocoderServiceInterface $geocoder,
    ) {
    }

    public function queryCoordinate(string $query): Coordinate
    {
        $requestParameters = ForwardGeocodingQueryRequestParameters::make($query)
            ->addCountryCode('nl')
            ->includeAddressDetails();

        $response = $this->geocoder->requestForwardGeocoding($request);

        return $response->getItems()[0]->getCoordinate();
    }
}
```

### PSR HTTP

[](#psr-http)

The underlying `Client` class uses [Discovery](https://docs.php-http.org/en/latest/discovery.html) by default to get instances of the following contracts:

- `Psr\Http\Client\ClientInterface`
- `Psr\Http\Message\RequestFactoryInterface`
- `Psr\Http\Message\UriFactoryInterface`

This means that you need to include (a) PSR compatible package(s) [in your project](https://docs.php-http.org/en/latest/httplug/users.html).

If you already have setup a specific HTTP client configuration in your project, which you would also like to use for Nominatim requests, you can pass these in by extending the service provider.

#### 1. Disable package discovery

[](#1-disable-package-discovery)

`composer.json`

```
"extra": {
    "laravel": {
        "dont-discover": [
            "wimski/laravel-nominatim"
        ]
    }
}
```

#### 2. Extend service provider

[](#2-extend-service-provider)

```
