c6digital / mapit-php
Third-party PHP SDK for MapIt.
Fund package maintenance!
c6digital
Requires
- php: ^8.2
- illuminate/contracts: ^11.5
- illuminate/http: ^11.5
Requires (Dev)
- laravel/pint: ^1.0
- pestphp/pest: ^2.15
- spatie/ray: ^1.28
This package is auto-updated.
Last update: 2024-11-08 13:38:14 UTC
README
This package provides a lightweight SDK to interact with MapIt APIs. It doesn't have methods for everything, only the things that we as an organisation frequently use.
Installation
You can install the package via Composer:
composer require c6digital/mapit-php
Usage
use C6Digital\MapIt\MapIt; $mapIt = new MapIt( key: 'your-mapit-key-here', // Your MapIt API key / token. url: 'https://mapit.mysociety.org' // An optional MapIt URL. );
Laravel
If you're using Laravel, this package provides a service provider that automatically registers the MapIt
class and uses .env
variables to configure the key and URL.
MAPIT_KEY=... MAPIT_URL=...
You can then request it from the container when you need to use it.
use C6Digital\MapIt\MapIt; class MyController { public function __invoke(MapIt $mapIt) { // ... } }
Retrieving postcodes
$mapIt->postcode('SW1P 3BD');
Throwing when errors occur
$mapIt->throw()->postcode(...);
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.