├── LICENSE ├── README.md ├── composer.json └── src ├── LaravelFacade.php └── LaravelServiceProvider.php /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Menara Solutions 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # geographer-laravel 2 | Laravel (and Lumen) integration for Geographer 3 | 4 | ## Getting started 5 | 6 | Install Laravel integration package first: 7 | 8 | ``` 9 | $ composer require menarasolutions/geographer-laravel 10 | ``` 11 | 12 | Good news is that Laravel will take care of singleton instance for you, so no matter how many times you call it – it's the same object. 13 | 14 | > In Laravel 5.5, [service providers and aliases are automatically registered](https://laravel.com/docs/5.5/packages#package-discovery). If you're using Laravel 5.5, skip ahead. 15 | 16 | ```php 17 | // Add in your config/app.php 18 | 19 | 'providers' => [ 20 | '...', 21 | MenaraSolutions\Geographer\Integrations\LaravelServiceProvider::class, 22 | ]; 23 | 24 | 'aliases' => [ 25 | '...', 26 | 'Geographer' => MenaraSolutions\Geographer\Integrations\LaravelFacade::class, 27 | ]; 28 | 29 | // Start playing with it, all the same calls 30 | Geographer::getCountries()->useShortNames()->toArray(); 31 | ``` 32 | 33 | Full list of methods is available in [Geographer documentation](https://github.com/MenaraSolutions/geographer) 34 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "menarasolutions/geographer-laravel", 3 | "type": "library", 4 | "description": "Geographer integration classes for Laravel and Lumen", 5 | "keywords": ["laravel","geographer","geolocation","localization"], 6 | "homepage": "https://github.com/MenaraSolutions/geographer-laravel", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Denis Mysenko", 11 | "email": "denis@menara.com.au", 12 | "homepage": "https://www.menara.com.au" 13 | } 14 | ], 15 | "require": { 16 | "php": ">=5.5.0", 17 | "menarasolutions/geographer": "^0.3.0" 18 | }, 19 | "require-dev": { 20 | "illuminate/support": "5.*" 21 | }, 22 | "autoload": { 23 | "psr-4": { 24 | "MenaraSolutions\\Geographer\\Integrations\\": "src/" 25 | } 26 | }, 27 | "extra": { 28 | "laravel": { 29 | "providers": [ 30 | "MenaraSolutions\\Geographer\\Integrations\\LaravelServiceProvider" 31 | ], 32 | "aliases": { 33 | "Geographer": "MenaraSolutions\\Geographer\\Integrations\\LaravelFacade" 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/LaravelFacade.php: -------------------------------------------------------------------------------- 1 | app->singleton('geographer', function() { 37 | return new Earth(); 38 | }); 39 | } 40 | /** 41 | * Get the services provided by the provider. 42 | * 43 | * @return array 44 | */ 45 | public function provides() 46 | { 47 | return ['geographer']; 48 | } 49 | } 50 | --------------------------------------------------------------------------------