- How do I install and use this package in Laravel 12?
- Run `composer require arthurydalgo/laravel-iso-countries` to install. No migrations are required—the package bundles a SQLite database. Access data via Eloquent models like `Country::find('US')` or `Currency::find('EUR')`. Ensure your Laravel app uses PHP 8+ for compatibility.
- Does this package support Laravel 10 or older versions?
- This fork explicitly supports Laravel 11/12 and PHP 8+. For Laravel 7–10, use version 2 of the package or check the original repository for legacy support. Always verify version constraints in `composer.json` to avoid conflicts.
- Can I add custom translations for country/language names beyond the default locales (en, de, fr, es)?
- Yes, the package uses `spatie/laravel-translatable` for localization. You can extend translations by rebuilding the SQLite database with additional locales. Follow the [data updates guide](https://github.com/ArthurYdalgo/laravel-iso-countries) to compile a custom dataset.
- Will this package work in a microservices architecture where each service has its own database?
- No, this package embeds a SQLite database, which violates microservices principles. For distributed systems, consider migrating the data to PostgreSQL/MySQL or using a dedicated API like `restcountries.com`. Alternatively, extract the data manually and seed your own tables.
- How do I query countries that share a language or currency efficiently?
- Use the built-in relationships: `Language::find('es')->countries` returns all countries where Spanish is official. For currencies, `Currency::find('EUR')->countries` lists Eurozone nations. These queries are optimized via Eloquent’s many-to-many relationships—no raw SQL needed.
- Is the SQLite database file safe to commit to version control, or should I exclude it?
- Exclude the SQLite file (`database/iso_countries.sqlite`) from `.gitignore` in development but commit it for production consistency. For CI/CD pipelines, rebuild the database during deployment if you’ve customized translations. Document your approach to avoid environment mismatches.
- How do I handle updates when ISO standards change (e.g., new countries or currencies)?
- The package provides instructions to rebuild the SQLite database with updated ISO data. Monitor [ISO official sources](https://www.iso.org/iso-3166-country-codes.html) and rebuild the dataset as needed. There’s no automated update mechanism—manual intervention is required.
- Can I use this package in a headless Laravel API (e.g., GraphQL or REST)?
- Direct model access works, but you’ll need to wrap the data in API responses manually. For GraphQL, use Laravel GraphQL’s `Type` system to expose `Country`, `Language`, and `Currency` models. Consider caching frequent queries (e.g., `Country::all()`) to improve API performance.
- What are the performance implications of using SQLite for ISO data in a high-traffic app?
- SQLite is lightweight and performs well for small-to-medium datasets. For high-traffic features (e.g., checkout flows), cache queries like `Country::all()` or use Laravel’s query caching. Test under load—if performance degrades, migrate the data to PostgreSQL/MySQL for better scalability.
- How does this package compare to alternatives like `laravel-countries` or `michiellis/iso-3166`?
- This package stands out by bundling **all three ISO standards (3166, 639-1, 4217)** with **predefined relationships** (e.g., `Country::find('LU')->languages`). Alternatives like `laravel-countries` focus only on countries and lack multi-language support or currency data. Choose this if you need a unified solution.