A Zend Framework 2 module for country and subdivision data. This module integrates lib-country with Zend Framework 2.
Please read the docs of lib-country first.
// From ServiceManager
/** @var Phine\Country\Loader\Loader $countryLoader */
$countryLoader = $serviceManager->get('CountryLoader');
$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
$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)
- Add
"hrevert/ht-country-module": "1.0.*"
to composer.json and runphp composer.phar update
- Register
HtCountryModule
as module inconfig/application.config.php