codepil0t / laravel-country-flags
A Laravel package for country flags
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/codepil0t/laravel-country-flags
Requires
- php: >=7.3
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0|^8.0|^9.0|^10.0
README
This package provides country flags for Laravel applications (compatible with Laravel 8+ up to Laravel 12).
Installation
Install via Composer:
composer require codepil0t/laravel-country-flags
Publishing Assets
Publish the flag assets to your public directory:
php artisan vendor:publish --tag=flags
This will copy the flags to public/flags/.
Usage
In Blade Templates
Use the @flag directive:
<img src="@flag('de')" alt="Germany Flag">
Or use the helper function:
<img src="{{ flag_url('de') }}" alt="Germany Flag">
You can specify the aspect ratio (1x1 or 4x3, default is 4x3):
<img src="{{ flag_url('de', '1x1') }}" alt="Germany Flag">
In PHP
echo flag_url('de'); // /flags/4x3/de.svg
Supported Countries
All ISO 3166-1 alpha-2 country codes are supported.