Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Pragmarx Countries

Pragmarx Countries Laravel Package

upmind/pragmarx-countries

Laravel package providing countries, states, cities, currencies, and timezones with bundled data, Eloquent models, validation rules, caching, and helpers for forms and APIs. Use it to populate selects, validate addresses, and localize geographic data. A maintained fork of pragmarx/countries by Upmin...

Deep Wiki
Context7

A Laravel package for working with country data in PHP applications. The Upmind fork of pragmarx/countries provides reliable country metadata and convenient helpers for looking up, validating, and presenting countries without maintaining your own datasets.

  • ISO 3166 data: names, alpha-2/alpha-3 codes, numeric codes, and calling codes.
  • Laravel integration: service provider, helpers, and configurable data sources.
  • Validation support: rules for country codes and related fields.
  • Presentation helpers: flags, currencies, and formatted country information.
  • Extensible: swap or extend datasets to fit application needs.
Frequently asked questions about Pragmarx Countries
How do I install upmind/pragmarx-countries in a Laravel app?
Run composer require upmind/pragmarx-countries. Laravel package auto-discovery registers the service provider and facade, so manual provider entries are usually unnecessary. Publish the package configuration if you need to customize data sources or cache settings.
What is the difference between upmind/pragmarx-countries and pragmarx/countries?
It is a fork of pragmarx/countries that adds PHP 8 and psr/cache 3.0 compatibility. The country lookup API and Laravel integration are intended to remain familiar, so it can work as a drop-in replacement when upgrading PHP or cache dependencies. Check version constraints before swapping it into an existing application.
Does this package support Laravel 10 and Laravel 11?
Compatibility depends on the illuminate/support constraints declared in the fork's composer.json. Because the fork specifically targets PHP 8 and newer PSR cache interfaces, it is aimed at modern Laravel applications. Check Packagist for the exact Laravel version range before installing.
How do I create a country select dropdown with this Laravel package?
Use the Countries facade to retrieve the country collection, then map or pluck display names and ISO codes for your form options. A common approach is to pluck the common name keyed by the two-letter code so the submitted value is a stable ISO code. Sort the collection by name before passing it to your Blade view.
How can I look up a country by ISO code?
Query the Countries collection using the relevant ISO field, such as cca2 for two-letter codes or cca3 for three-letter codes. The result is a country object containing name, currency, calling code, and other metadata. Cache repeated lookups in your own service layer if you resolve the same codes frequently.
How do I get currencies and phone prefixes for a country?
Each country record exposes metadata such as currency and calling code, so you can read those properties after retrieving a country by ISO code. Use them to prefill address forms, show dialing prefixes, or format prices. Validate any prefilled values against your own business rules before saving them.
Can I use this package to validate country codes in Laravel?
Yes, you can build a Laravel validation rule or use an in: rule backed by the ISO codes returned by the package. The fork provides country data and lookup helpers that make it straightforward to confirm a submitted code exists. For form requests, resolve the allowed list once and reuse it rather than querying per field.
How does caching work and why does psr/cache 3.0 matter?
The package can cache country data through a PSR cache implementation, and the fork updates support to psr/cache 3.0 so it can work with modern cache libraries. In Laravel, configure the cache adapter in the package config to avoid repeatedly loading the full country dataset. This matters most in production where address forms and validation rules are used on every request.
Is upmind/pragmarx-countries safe to use in production?
It is a compatibility fork maintained for applications that need PHP 8 and newer PSR cache support. Review the repository activity, release history, and test coverage before adopting it for critical workflows. Pin a specific version in composer.json and run your own integration tests for country selection and validation.
What alternatives should I consider?
The original pragmarx/countries is the closest alternative if your PHP and cache versions are compatible. Other options include rinvex/country for Laravel-friendly country data and league/iso3166 for lower-level ISO 3166 handling. Choose based on whether you need Laravel facades, localization, currencies, phone prefixes, or only ISO code lists.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager