Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

WouterSioen/country-list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Abandoned

You can do the same things as with this package using the symfony/intl component https://symfony.com/doc/master/components/intl.html#country-names

Country list

A wrapper around https://github.com/umpirsky/country-list to easily fetch a list of countries in a certain language or get a specific country by country code and language.

Installing

composer.json

{
    "require": {
        "woutersioen/country-list": "dev-master"
    }
}

index file for your project

// update this to the path to the "vendor/" directory, relative to this file
require_once '../vendor/autoload.php';

Usage

With dependency injection container:

First add an instance of the class Sioen\Countries to your dependency injection container.

// fetch an array of countries in a language
$languages = $this->getContainer()->get('countries')->getForLanguage('en');

// fetch one country in a language
$language = $this->getContainer()->get('countries')->getSpecificForLanguage('be', 'en');
// returns 'Belgium'

Most modern PHP Frameworks have a dependency injection container. This is the prefered way, since there will only be one instance of the countries object, and data will be cached in this object.

PHP 5.4 (+)

use Sioen\Countries;

// fetch an array of countries in a language
$languages = (new Countries)->getForLanguage('en');

// fetch one country in a language
$language = (new Countries)->getSpecificForLanguage('be', 'en');
// returns 'Belgium'

PHP 5.3

use Sioen\ContryList;

$countries = new Countries();

// fetch an array of countries in a language
$languages = $countries->getForLanguage('en');

// fetch one country in a language
$language = $countries->getSpecificForLanguage('be', 'en');
// returns 'Belgium'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages