- How do I install webpatser/laravel-countries in a Laravel app?
- Install it with composer require webpatser/laravel-countries, then run php artisan countries:install to create and seed the country data table. The package badge lists PHP ^8.2, so confirm your runtime before installing. After installation, you can use the Countries class or the Eloquent model in your application.
- Does webpatser/laravel-countries support Laravel 11, 12, and 13?
- The README badge shows Laravel ^11.0 | ^12.0 | ^13.0, but compatibility claims have been inconsistent across the package description and badges. Check composer.json in the exact tagged release you plan to use and pin a tested combination. Do not rely on marketing copy alone for your version matrix.
- Does webpatser/laravel-countries include ISO 3166-2 subdivisions such as US states?
- The overview promises ISO 3166-2, but the feature list and quick usage examples only demonstrate country-level data, currencies, regions, and flags. The short description hedges with the phrase Almost ISO 3166_2, so subdivision support should be treated as unproven. Run a small spike against the installed package before depending on it for state or province dropdowns.
- Does webpatser/laravel-countries support ISO 3166-3 historical country codes?
- ISO 3166-3 is mentioned in the package overview but is not demonstrated in the README feature list or usage examples. If you need deprecated or historical country codes, verify the database schema and data after installation. Otherwise, assume the package covers the 249 currently assigned country codes.
- How do I get all countries that use a specific currency, such as EUR?
- Use the getByCurrency helper on the Countries class, for example getByCurrency('EUR') to return countries using the euro. The same class exposes getOne('US') for a single record and getList() for the full country list. The package also supports Eloquent model queries if you prefer database filtering.
- How do I validate a country code in Laravel with this package?
- The package advertises Laravel validation rules that you can add to form requests or validator calls. Confirm the exact rule name and behavior in the documentation for your installed version. Pair the rule with the package's seeded country data so validation stays consistent with your dropdown source.
- Where does webpatser/laravel-countries store its country data?
- It is database-backed: the countries:install command creates and seeds a table, and an Eloquent model queries it. Country data is near-static, but because it lives in your application database, every environment, test database, and CI runner needs the installer or seeder to run. For polyglot estates, consider a canonical JSON file or internal reference-data endpoint instead of a package-scoped table.
- Why is country data missing in my tests or CI pipeline?
- The package relies on a seeded database table, so ephemeral test databases will not have country records unless you run the installation or seed step. Add countries:install or the equivalent seeding to your test setup and CI pipeline. If that coupling is undesirable, use a file- or config-backed country source for tests.
- Does webpatser/laravel-countries include flag emojis and official country names?
- Yes, the package advertises flag emojis for every country plus both a common name and a full official name. For example, getOne('US') returns United States as the name and United States of America as the full_name. These fields are useful for address forms, reporting, and flag-bearing UI.
- What are alternatives to webpatser/laravel-countries?
- Alternatives include a checked-in JSON or CSV country list, other Laravel country-data packages, or a shared internal reference-data service. The right choice depends on whether you need subdivisions, historical codes, multi-language names, or usage outside PHP. For polyglot systems, a single canonical country source is usually safer than a package-specific database table.