API Reference
Complete reference for all classes, methods, and functions.
Countries Class
The main class for accessing country data.
Get a single country by ISO code
Get all countries, optionally sorted
Filter countries by currency code
Filter countries by region
Search countries by name or capital
Get formatted options for select inputs
Get countries as Laravel Collection
Country Data Structure
Each country contains the following fields:
[ 'name' => 'United States', // Official country name 'capital' => 'Washington D.C.', // Capital city 'iso_3166_2' => 'US', // ISO 3166-2 code (2 letters) 'iso_3166_3' => 'USA', // ISO 3166-3 code (3 letters) 'currency_code' => 'USD', // ISO 4217 currency code 'currency_name' => 'US Dollar', // Currency name 'currency_symbol' => '$', // Currency symbol 'calling_code' => '1', // International calling code 'region' => 'North America', // Geographic region 'languages' => ['en'], // Array of language codes 'flag' => 'πΊπΈ', // Flag emoji]
Helper Functions
Global helper functions for quick access:
Get country name
Get country flag emoji
Get capital city
Get currency information
Get formatted name with flag
Check if country code exists
Get countries in a region
Get countries using currency
Collection Macros
Extended Collection methods for country data:
Filter by country code
Filter by region
Filter by currency
Search countries
Extract country names
Extract country codes
Extract flag emojis
Add display_name with flags
String Macros
Extended Str class methods:
Convert code to flag emoji
Convert flag to country code
Get country name
Validation Rules
Custom validation rules for forms:
Validate country codes
Validate currency codes
Validate region names