Skip to content

hrevert/HtCountryModule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HtCountryModule

Master Branch Build Status Latest Stable Version Total Downloads Scrutinizer Code Quality Code Coverage

A Zend Framework 2 module for country and subdivision data. This module integrates lib-country with Zend Framework 2.

Requirements

Usage

Please read the docs of lib-country first.

Using Services

// From ServiceManager
/** @var Phine\Country\Loader\Loader $countryLoader */
$countryLoader = $serviceManager->get('CountryLoader');

Using hydrator strategy

$strategy = new HtCountryModule\Hydrator\Strategy\CountryStrategy;
// or $strategy = $serviceManager->get('HtCountryModule\Hydrator\Strategy\CountryStrategy');

/** @var Phine\Country\Country $country */
$country = $strategy->hydrate('US');

echo $strategy->extract($country); // will print US

Using country validator

$validator = new HtCountryModule\Validator\CountryValidator;
// or $validator = $serviceManager->get('ValidatorManager')->get('CountryValidator');
var_dump($validator->isValid('asdfasfd')); // bool(false)
var_dump($validator->isValid('US')); // bool(true)

Installation

  • Add "hrevert/ht-country-module": "1.0.*" to composer.json and run php composer.phar update
  • Register HtCountryModule as module in config/application.config.php