Offline country data for PHP Laravel framework. Over 200 countries, capitals, flags, languages, currencies. No internet needed.
This packages uses the 7 model continent, and this is a Reference for all the countries included.
cd my-laravel-project
composer require ayoub-amzil/offline-globe
Import class
use offline\Globe;
Create an instance
$globe = new Globe();
Functions available
Return an array type value of all countries available
$globe->Countries()
Return an array type value of African countries
$globe->African()
Return an array type value of Asian countries
$globe->Asian()
Return an array type value of Australian countries
$globe->Australia()
Return an array type value of European countries
$globe->Europe()
Return an array type value of North America countries
$globe->NorthAmerica()
Return an array type value of South America countries
$globe->SouthAmerica()
Return the country code of the given country. The function accept one argument of type string.
$globe->Code('Morocco') // MA (return type: string)
Return the capital of the given country. The function accept one argument of type string.
$globe->Capital('japan') // Tokyo (return type: string)
Return the Languages spoken in the given country. The function accept one argument of type string.
$globe->Language('jamaica') // ['english', 'jamaican_patois'] (return type: array)
Return the currency used in the given country. The function accept one or two arguments
// It can take only the country (mandatory)
$globe->Currency('Canada') // ['name' => 'Canadian Dollar', 'code' => 'CAD'] (return type: array)
// Or the country plus one type of information
// name (option)
$globe->Currency('canada','name') // Canadian Dollar (return type: string)
// code (option)
$globe->Currency('canada','code') // CAD (return type: string)
Return the flag of the given country. The function accept three arguments. Country, type of the flag, and a directory name where the flags are saved.
// country (mandatory)
return view('welcome',
['flag'=>$globe->flag('united states')]
); // (return type: string)
// In your template
<img src="https://github.com/ayoub-amzil/{{$flag}}" alt="image">
// type (option) [default=svg]
return view('welcome',
['flag'=>$globe->flag('united states','png')]
); // (return type: string)
// In your template
<img src="https://github.com/ayoub-amzil/{{$flag}}" alt="image">
// directory name (option) [default=flags]
// PS: if you want to change your directory name, you have to set the type before
return view('welcome',
['flag'=>$globe->flag('united states','png','images')]
); // (return type: string)
// In your template
<img src="https://github.com/ayoub-amzil/{{$flag}}" alt="image">
Contributions are always welcome!
Leave a Reply