- What is league/iso3166 used for in Laravel applications?
- Use league/iso3166 when you need reliable ISO 3166-1 country data in a Laravel app for form validation, country normalization, dropdown labels and values, or mapping countries to currency codes. It is a lightweight in-memory data provider with simple lookup methods, so it fits validation and data-cleaning workflows without an external service.
- How do I install league/iso3166 with Composer in a Laravel project?
- Install it with Composer by running composer require league/iso3166 from your Laravel project root. No manual file copying or framework-specific setup is described; Composer autoloading makes the classes available.
- Do I need to register a service provider or publish config for league/iso3166?
- No service provider registration, config publishing, or environment setup is documented for Laravel. It is a plain PHP library, so you can instantiate the ISO3166 class directly where needed.
- Which Laravel versions are compatible with league/iso3166?
- There is no Laravel-specific version constraint documented because league/iso3166 is a plain Composer package. Compatibility depends on your application's PHP version and Composer resolving the package, so check the package requirements for your Laravel version.
- What data does league/iso3166 return for a country?
- Each lookup returns a structured array containing the country name, alpha2 code, alpha3 code, numeric code, and currency codes. For example, the Netherlands record includes name, alpha2 NL, alpha3 NLD, numeric 528, and currency EUR.
- Can I look up a country by name, alpha-2, alpha-3, or numeric code?
- Yes, the ISO3166 class exposes name(), alpha2(), alpha3(), and numeric() lookup methods. You can retrieve the same structured country record by any of those identifiers.
- Does league/iso3166 include currency information?
- Yes, the returned country array includes a currency field with one or more currency codes, such as EUR for the Netherlands. Because the package focuses on ISO 3166-1 data, confirm data freshness for countries with recent currency changes.
- How do I test league/iso3166 lookups in a Laravel test suite?
- Because the library is stateless and in-memory, unit tests can assert known country mappings and how your app handles invalid lookups without mocking HTTP services. Add tests for the specific codes your forms accept and for any normalization rules you apply around the package.
- Is league/iso3166 production-ready, and what alternatives should I consider?
- It is lightweight, has no external service dependency, and is suitable for production validation and normalization tasks when your data-freshness needs are modest. Main concerns are the package's ISO 3166-1-only scope and keeping country and currency data current; alternatives include maintaining your own ISO table or choosing a broader geographic dataset if you need subdivisions or historical codes.
- Is league/iso3166 actively maintained and does it handle historical or deprecated country codes?
- league/iso3166 is maintained by The PHP League under the MIT license, and the README invites issues for errors or omissions. The documentation describes current ISO 3166-1 lookups and does not advertise historical or deprecated-code resolution, so treat it as a current-data library. The provided assessment flags a possibly erroneous last-release date and low dependent count, so review release history before adopting.