Countries for Laravel

v0.7.0 2020-03-26 09:17 UTC

This package is auto-updated.

Last update: 2023-03-19 15:30:12 UTC


World Map

Latest Stable Version License Code Quality Build

Coverage PHP Downloads StyleCI

What does it gives you?

This package has all sorts of information about countries:

info items
taxes 32
geometry maps 248
topology maps 248
currencies 256
countries 266
timezones 423
borders 649
flags 1,570
states 4,526
cities 7,376
timezones times 81,153


The validation is extending Laravel's validation, so you can use it like any other validation rules, like

 * Store a new blog post.
 * @param  Request  $request
 * @return Response
public function store(Request $request)
    $this->validate($request, [
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
        'country' => 'country' //Checks if valid name.common

    // The blog post is valid, store in database...

Which validation rules there is and what there name should be, can all be configured in the configuration file.

'validation' => [
    'rules' => [
	    'countryCommon' => 'name.common'

By changing the configuration like this, we can now access the property name.common, by the validation rule countryCommon

You have to define all the validations rules in settings, only a few is defined by default, the default is

'rules' 	=> [
    'country' 			=> 'name.common',
    'currencies'			=> 'ISO4217',
    'language_short'	=> 'ISO639_3',


This package is a Laravel bridge, please refer to the main package repository for more information and docs.


  • PHP 7.0+
  • Laravel 5.5+


Use Composer to install it:

composer require pragmarx/countries-laravel

Publishing assets

You can publish configuration by doing:

php artisan vendor:publish --provider=PragmaRX\\CountriesLaravel\\Package\\ServiceProvider


After installing you'll have access to the Countries Façade, and the package is based on Laravel Collections, so you basically have access to all methods in Collections, like

$france = Countries::where('name.common', 'France');

Flag routes

You can refer directly to an SVG flag by linking




These routes can be turned off in the configuration file:

'routes' => [
    'enabled' => false,


Antonio Carlos Ribeiro


Countries is licensed under the MIT License - see the LICENSE file for details


Pull requests and issues are more than welcome.