2017 © Pedro Peláez
 

library php-countries

PHP Countries is a library that provides an elegant syntax to country data.

image

rapidwebltd/php-countries

PHP Countries is a library that provides an elegant syntax to country data.

  • Wednesday, March 21, 2018
  • by DivineOmega
  • Repository
  • 4 Watchers
  • 1 Stars
  • 44 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

PHP Countries

Build Status Coverage Status StyleCI, (*1)

PHP Countries is a library that provides an elegant syntax to country data., (*2)

Installation

You can install PHP Countries via Composer, as follows., (*3)

composer require rapidwebltd/php-countries

Usage

To use PHP Countries, you must create a new Countries object., (*4)

use RapidWeb\Countries\Countries;

$countries = new Countries;

You can then call various methods on this object, to get country data., (*5)

Retrieving all countries

You can easily retrieve an array of all countries and iterate through them, as follows., (*6)

foreach($countries->all() as $country) {
    var_dump($country->name.' - '.$country->officialName);
}

Retrieving country by name

Country details can be retrieved from the country's official or common name., (*7)

var_dump($countries->getByName('United Kingdom'));

/* 
object(RapidWeb\Countries\Country)#4869 (16) {
  ["name"]=>
  string(14) "United Kingdom"
  ["officialName"]=>
  string(52) "United Kingdom of Great Britain and Northern Ireland"
  ["topLevelDomains"]=>
  array(1) {
    [0]=>
    string(3) ".uk"
  }
  ["isoCodeAlpha2"]=>
  string(2) "GB"
  ["isoCodeAlpha3"]=>
  string(3) "GBR"
  ["isoCodeNumeric"]=>
  string(3) "826"
  ["languages"]=>
  array(1) {
    [0]=>
    string(7) "English"
  }
  ["languageCodes"]=>
  array(1) {
    [0]=>
    string(3) "eng"
  }
  ["currencyCodes"]=>
  array(1) {
    [0]=>
    string(3) "GBP"
  }
  ["callingCodes"]=>
  array(1) {
    [0]=>
    string(2) "44"
  }
  ["capital"]=>
  string(6) "London"
  ["region"]=>
  string(6) "Europe"
  ["subregion"]=>
  string(15) "Northern Europe"
  ["latitude"]=>
  int(54)
  ["longitude"]=>
  int(-2)
  ["areaInKilometres"]=>
  int(242900)
}
*/

Retrieving country by ISO 3166-1 code

You can get the data for a country by its ISO 3166-1 code. The 2 character, 3 character and numeric variations are all accepted., (*8)

var_dump($countries->getByIsoCode('USA'));

/*
object(RapidWeb\Countries\Country)#4693 (16) {
  ["name"]=>
  string(13) "United States"
  ["officialName"]=>
  string(24) "United States of America"
  // etc...
}
*/

Retrieving country by language spoken

Providing a language, will return an array of all countries in which that language is spoken. You can provide a language name or code., (*9)

var_dump($countries->getByLanguage('German'));

/*
array(5) {
  [0]=>
  object(RapidWeb\Countries\Country)#4913 (16) {
    ["name"]=>
    string(7) "Belgium"
    ["officialName"]=>
    // etc...
  }
  [1]=>
  object(RapidWeb\Countries\Country)#4883 (16) {
    ["name"]=>
    string(7) "Germany"
    ["officialName"]=>
    string(27) "Federal Republic of Germany"
    // etc...
  }
  [2]=>
  object(RapidWeb\Countries\Country)#4826 (16) {
    ["name"]=>
    string(13) "Liechtenstein"
    ["officialName"]=>
    string(29) "Principality of Liechtenstein"
    // etc...
  }
  [3]=>
  object(RapidWeb\Countries\Country)#4808 (16) {
    ["name"]=>
    string(10) "Luxembourg"
    ["officialName"]=>
    string(25) "Grand Duchy of Luxembourg"
    // etc...
  }
  [4]=>
  object(RapidWeb\Countries\Country)#4871 (16) {
    ["name"]=>
    string(7) "Namibia"
    ["officialName"]=>
    string(19) "Republic of Namibia"
    // etc...
  }
}
*/

The Versions

21/03 2018

dev-master

9999999-dev

PHP Countries is a library that provides an elegant syntax to country data.

  Sources   Download

LGPL3 LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

21/03 2018

v1.0.5

1.0.5.0

PHP Countries is a library that provides an elegant syntax to country data.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

21/03 2018

dev-analysis-qJWegD

dev-analysis-qJWegD

PHP Countries is a library that provides an elegant syntax to country data.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

21/03 2018

dev-analysis-qxRvDa

dev-analysis-qxRvDa

PHP Countries is a library that provides an elegant syntax to country data.

  Sources   Download

LGPL-3.0-only

The Requires

 

The Development Requires

by Jordan Hall

13/02 2018

dev-analysis-XNemN1

dev-analysis-XNemN1

PHP Countries is a library that provides an elegant syntax to country data.

  Sources   Download

LGPL-3.0-only

The Requires

 

by Jordan Hall

30/01 2018

v1.0.4

1.0.4.0

PHP Countries is a library that provides an elegant syntax to country data.

  Sources   Download

LGPL-3.0-only

The Requires

 

by Jordan Hall

30/01 2018

v1.0.3

1.0.3.0

PHP Countries is a library that provides an elegant syntax to country data.

  Sources   Download

LGPL-3.0-only

The Requires

 

by Jordan Hall

14/09 2017

v1.0.2

1.0.2.0

PHP library providing elegant syntax to country data

  Sources   Download

LGPL3

The Requires

 

by Jordan Hall

14/09 2017

v1.0.1

1.0.1.0

PHP library providing elegant syntax to country data

  Sources   Download

LGPL3

The Requires

 

by Jordan Hall

14/09 2017

v1.0.0

1.0.0.0

PHP library providing elegant syntax to country data

  Sources   Download

LGPL3

The Requires

 

by Jordan Hall