mehr-it/lara-countries

Extendable multilingual, countries list for Laravel
1,413
Install
composer require mehr-it/lara-countries
Latest Version:1.4.0
PHP:>=7.1
License:MIT
Last Updated:Apr 19, 2023
Links: GitHub  ·  Packagist
Maintainer: mehr-it

Lara Countries

Latest Version on Packagist Build Status

Localized country and language list for Laravel with all ISO codes.

Country list contains following data:

  • alpha-2 country code (ISO 3166-1)
  • alpha-3 country code (ISO 3166-1)
  • Country name (in all locales)
  • Dialing code (eg. 49 for Germany)

Language list contaings following data:

  • alpha-2 language code (ISO 639-1)
  • Language name (in all locales)

Unlike many other packages, it does not use a hardcoded list but imports the selected data to the database. For faster performance the data is cached locally in PHP files which are synchronized via the central application cache.

This way you get best performance but are still free to edit data.

Installation

Install the package using composer. Laravel's package auto discovery will do the rest for you:

composer require  mehr-it/lara-countries

Import country data

After installation you have to import data to the database: To import the country/language list, run following command:

artisan countries:import
artisan languages:import

This imports the country/language list. If you need any other locale than "en", you can import them using following command:

artisan countries:importLocale de
artisan languages:importLocale de

Usage

You can access country information using the Countries facade:

// get country information
Countries::get('US');

// get country information with other locale than the application locale
Countries::get('US', 'de');

// check if country code exists
Countries::exists('US');

// list all countries
Countries::all();

// list all countries with other locale than the application locale
Countries::all('de');

// list all iso2 codes
Countries::allIso2Codes();

You can access language information using the Languages facade:

// get language information
Languages::get('en');

// get language information with other locale than the application locale
Languages::get('en', 'de');

// check if language code exists
Languages::exists('US');

// list all languages
Languages::all();

// list all languages with other locale than the application locale
Languages::all('de');

// list all iso2 codes
Languages::allIso2Codes();

Related Packages

gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

628,058,007 9,707
laravel/framework

The Laravel Framework.

576,155,700 34,907
laravel/tinker

Powerful REPL for the Laravel framework.

485,678,092 7,440