hrevert/ht-country-module

A Zend Framework 2 module for country and subdivision data.

1.0.1 2014-11-21 15:32 UTC

This package is auto-updated.

Last update: 2024-11-13 02:52:21 UTC


README

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