PHPackages                             danielebuso/laravel-countries - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. danielebuso/laravel-countries

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

danielebuso/laravel-countries
=============================

A Laravel package providing country data with multilanguage support using Sushi

1.0.0(3mo ago)0209↓33.3%[1 PRs](https://github.com/danielebuso/laravel-countries/pulls)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Feb 4Pushed 1mo agoCompare

[ Source](https://github.com/danielebuso/laravel-countries)[ Packagist](https://packagist.org/packages/danielebuso/laravel-countries)[ Docs](https://github.com/danielebuso/laravel-countries)[ GitHub Sponsors](https://github.com/danielebuso)[ RSS](/packages/danielebuso-laravel-countries/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (14)Versions (4)Used By (0)

Laravel Countries
=================

[](#laravel-countries)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bfaf350ed628fc604a009a0b1f8c0a3410eaeda111cffa34ee56dc814c9bd1da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616e69656c656275736f2f6c61726176656c2d636f756e74726965732e737667)](https://packagist.org/packages/danielebuso/laravel-countries)[![Total Downloads](https://camo.githubusercontent.com/8fba6073227a3caf02f96cf0eabbdbeb59454a6831fd15cbc9d14aa00cce40ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64616e69656c656275736f2f6c61726176656c2d636f756e74726965732e737667)](https://packagist.org/packages/danielebuso/laravel-countries)

A Laravel package that provides an easy way to query and browse country data with **multilanguage support** using Sushi. Unlike other country packages, this one includes country names in multiple languages, making it perfect for international applications.

This package uses data structure inspired by [stefangabos/world\_countries](https://github.com/stefangabos/world_countries) and leverages [Sushi](https://github.com/calebporzio/sushi) to provide a seamless Eloquent-like interface for static country data.

Features
--------

[](#features)

- 🌍 Complete ISO 3166-1 list with 249 entities including countries, territories, and dependencies
- 🌐 **Multilanguage support** - Country names in multiple languages (English, Spanish, French, Italian, and more)
- 🔍 Query countries using Laravel's Eloquent ORM
- ⚡ Fast performance with Sushi's in-memory caching
- 🎯 Simple and intuitive API
- 📦 Zero database migrations required

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require danielebuso/laravel-countries
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-countries-config"
```

This is the contents of the published config file:

```
return [
    /*
     * The default locale to use when retrieving country names.
     * If not set, it will use Laravel's app locale.
     */
    'locale' => null,

    /*
     * Cache configuration for country data.
     * Sushi automatically caches the data, but you can configure it here.
     */
    'cache' => [
        'enabled' => true,
        'ttl' => 3600, // Time in seconds
    ],
];
```

Usage
-----

[](#usage)

### What's Included

[](#whats-included)

This package includes the complete ISO 3166-1 standard with **249 entities**:

- **Sovereign states**: All 193 UN member states plus Vatican City, Palestine, Kosovo, Taiwan
- **Territories**: Puerto Rico, Guam, U.S. Virgin Islands, American Samoa, etc.
- **Dependencies**: Greenland, Bermuda, French Polynesia, Faroe Islands, etc.
- **Special Administrative Regions**: Hong Kong, Macau
- **Other entities**: Antarctica, Åland Islands, and more

This comprehensive list ensures you have access to all officially recognized ISO codes, not just UN member states.

### Basic Usage

[](#basic-usage)

```
use Danielebuso\LaravelCountries\Models\Country;

// Get all countries
$countries = Country::all();

// Find a country by alpha-2 code
$usa = Country::where('alpha2', 'US')->first();

// Find a country by alpha-3 code
$italy = Country::where('alpha3', 'ITA')->first();

// Get countries sorted by name
$countries = Country::orderBy('name')->get();
```

### Multilanguage Support

[](#multilanguage-support)

The package includes built-in support for multiple languages. Country names are available in:

- English (en) - Default
- Spanish (es)
- French (fr)
- Italian (it)
- German (de)

```
use Danielebuso\LaravelCountries\Models\Country;

// Get country name in a specific language
$italy = Country::where('alpha2', 'IT')->first();

// Get name in Italian
$italianName = $italy->getName('it'); // Returns "Italia"

// Get name in Spanish
$spanishName = $italy->getName('es'); // Returns "Italia"

// Get name in French
$frenchName = $italy->getName('fr'); // Returns "Italie"

// Get name using app's current locale
app()->setLocale('es');
$localizedName = $italy->getName(); // Returns "Italia" (Spanish)
```

### Query Examples

[](#query-examples)

```
// Search countries by name
$countries = Country::where('name', 'LIKE', '%United%')->get();

// Get a specific country
$germany = Country::where('alpha2', 'DE')->first();
echo $germany->name; // Germany
echo $germany->alpha3; // DEU
echo $germany->id; // 276

// Count all countries
$total = Country::count();

// Pagination
$countries = Country::paginate(20);
```

### Available Fields

[](#available-fields)

Each country model has the following attributes:

- `id` - ISO 3166-1 numeric code
- `alpha2` - ISO 3166-1 alpha-2 code (e.g., 'US', 'IT', 'FR')
- `alpha3` - ISO 3166-1 alpha-3 code (e.g., 'USA', 'ITA', 'FRA')
- `name` - Country name in English

Why This Package?
-----------------

[](#why-this-package)

While there are several Laravel packages that provide country data, this package stands out because:

1. **Multilanguage Support**: Unlike most packages, this one includes country names in multiple languages out of the box
2. **No Database Required**: Uses Sushi to work with static data without migrations
3. **Familiar API**: Works just like any Eloquent model
4. **Actively Maintained**: Built on modern Laravel standards
5. **Lightweight**: Minimal dependencies and fast performance

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Daniele Buso](https://github.com/danielebuso)
- [All Contributors](../../contributors)
- Data structure inspired by [stefangabos/world\_countries](https://github.com/stefangabos/world_countries)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance86

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

98d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f71402d5c4de206cf25f6386b213b5ce7fcd214be6488eda25130ccc48394fc6?d=identicon)[danielebuso](/maintainers/danielebuso)

---

Top Contributors

[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (12 commits)")[![danielebuso](https://avatars.githubusercontent.com/u/6517317?v=4)](https://github.com/danielebuso "danielebuso (6 commits)")

---

Tags

laravelcountriesmultilanguageLaravel-Countriesdanielebusosushi

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/danielebuso-laravel-countries/health.svg)

```
[![Health](https://phpackages.com/badges/danielebuso-laravel-countries/health.svg)](https://phpackages.com/packages/danielebuso-laravel-countries)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
