Package Data | |
---|---|
Maintainer Username: | andela-tolotin |
Package Create Date: | 2016-06-07 |
Package Last Update: | 2020-05-16 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-26 15:02:01 |
Package Statistics | |
---|---|
Total Downloads: | 25 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 19 |
Total Watchers: | 5 |
Total Forks: | 9 |
Total Open Issues: | 3 |
If you have ever needed basic information about countries, and their states, then Locator is for you. Locator is a PHP package that works with the Yahoo API. It returns data that you need just by calling one method. There is a Service Provider and a Facade to make it easy to integrate with your Laravel project. It can also be used with other PHP frameworks like Lumen, CakePHP, Zend, etc. Version 1.0.0 only provides information about the following:
To use this package with a PHP project, first require the package using composer.
composer require claz/wishi
YAHOO_CLIENT_ID=*********************************
If you are using this project with a plain PHP project, follow the following steps:
composer dumpautoload
if required.require_once ('vendor/autoload.php')
use Wishi\Controllers\Locator;
$locator = new Locator();
If you are using this project with Laravel, follow the following steps:
Open app.config in config folder and,
Register the ServiceProvider inside config.php
Wishi\Providers\LocatorServiceProvider::class,
Locator => Wishi\Facades\Locator::class,
use Locator;
// With normal PHP applications
$countries = $locator->getCountries();
// With the Facade in Laravel applications
$countries = Locator::getCountries();
var_dump($countries); // Collection of countries
// With normal PHP applications
$states = $locator->getStates('Nigeria');
// With the Facade in Laravel applications
$states = Locator::getStates('Nigeria');
var_dump($states); // Collection of states
// With normal PHP applications
$counties = $locator->getCounties('Lagos');
// With the Facade in Laravel applications
$counties = Locator::getCounties('Lagos');
var_dump($counties); // Collection of counties
One very common use is illustrated below in a Laravel project that lists all the state in the Nigeria.
<ul>
@foreach(Locator::getStates('Nigeria') as $state)
<li> {{ $state->name }} </li>
@endforeach
</ul>
This project uses the MIT License feel free to contribute.