trickeyone / intl-subdivision
A PHP Intl library to retrieve states for a given country.
Installs: 42 927
Dependents: 2
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 6
Open Issues: 0
Requires
- php: ^7.1 || ^8.0
- symfony/intl: ^4.1 || ^5.0 || ^6.0
Requires (Dev)
- ext-json: *
- ext-xdebug: *
- mockery/mockery: ^1.0
- phpunit/phpunit: ^8.0 || ^9.0
- sokil/php-isocodes: ^3.3 || ^4.0
- sokil/php-isocodes-db-i18n: ^4.0
Suggests
- ext-intl: to use the component with locales other than "en"
README
A companion component to Symfony's Intl Component. This component allows for easy retrieval of a country's states/provinces using the country's ISO 3166-1 alpha-2 code.
The Symfony Intl component is a replacement for the C intl extension. It is limited to only the "en" locale. If you want to have access to more locales you should install the intl PECL extension.
Usage:
// States/Provinces for the United States of America $subdivisionsForUS = \Symfony\Component\IntlSubdivision\IntlSubdivision::getStatesAndProvincesForCountry('US'); // States/Provinces for Canada $subdivisionsForCA = \Symfony\Component\IntlSubdivision\IntlSubdivision::getStatesAndProvincesForCountry('CA'); // States/Provinces for the United Arab Emirates $subdivisionsForAE = \Symfony\Component\IntlSubdivision\IntlSubdivision::getStatesAndProvincesForCountry('AE');
Requirements
- PHP 7+ or 8+
- Symfony Intl package 5.0+ or 6.0+
- older versions can still support 4.0+ but are not actively supported