nakanakaii/filament-countries 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nakanakaii/filament-countries

Composer 安装命令:

composer require nakanakaii/filament-countries

包简介

This Package is a wrapper around `nakanakaii/countries` for filamentPHP

README 文档

README

This package is a wrapper around nakanakaii/countries tailored for Filament PHP. It provides ready-to-use Form components, Table columns, and Table filters for dealing with countries and phone numbers seamlessly.

Installation

You can install the package via composer:

composer require nakanakaii/filament-countries

If you wish to use the provided Image-based flags (instead of Unicode emojis), you must also publish the flags assets from the base countries package:

php artisan vendor:publish --tag=countries-flags

Next, conditionally publish and configure this plugin's settings:

php artisan vendor:publish --tag="filament-countries-config"

This will create a config/filament-countries.php file in your application where you can specify the global default flags provider:

return [
    'flags_provider' => 'emoji', // Options: 'emoji', 'image'
];

Form Components

Country Select

Provides a searchable select dropdown populated with countries.

use Nakanakaii\FilamentCountries\Forms\Components\CountrySelect;

CountrySelect::make('country_id')
    ->displayFlags(true) // Whether to prefix the country name with its flag (default: true)
    ->imageFlags()       // Force this specific field to use Image flags instead of Emojis
    ->emojiFlags()       // Force this specific field to use Emoji flags instead of Images

Customization:

If you wish to hide the flags from the options, you can use displayFlags(false).

CountrySelect::make('country_code')
    ->displayFlags(false)

Phone Input

Provides a text input configured for telephone numbers (type="tel"). By default, it is configured with live(onBlur: true) which allows it to react to the phone number and automatically fetch the Country Flag to use as a prefix, and automatically apply exact regex validation rules based on the user's entered dial code!

use Nakanakaii\FilamentCountries\Forms\Components\PhoneInput;

PhoneInput::make('phone_number')

Customization:

You can disable the automatic flag prefix or the automatic phone validation, or specifically enforce a flag rendering type:

PhoneInput::make('phone_number')
    ->displayFlags(false)
    ->applyValidation(false)
    ->imageFlags() // Explicitly return image-based flags for this field

If you are not using a country dial-code selector, or if you expect your users to primarily enter local phone numbers without their international + prefixes, you should configure the phone input to use a specific country for evaluation. This allows the package to understand the context and validate the local number properly by checking it against the right country format.

PhoneInput::make('phone_number')
    ->country('AE') // Validate the local number specifically for United Arab Emirates

You can also dynamically link the validation directly to another country form field by providing the field name!

CountrySelect::make('country')
    ->live(), // Important: ensure the country field is reactive if used dynamically!
PhoneInput::make('phone_number')
    ->countryField('country') // Dynamic validation based on the select above

Table Columns

Country Column

A text column that displays the country flag and name based on the country code.

use Nakanakaii\FilamentCountries\Tables\Columns\CountryColumn;

CountryColumn::make('country_code')
    ->displayFlags(true) // Show or hide the flag (default: true)
    ->hideName(false)    // Show or hide the country name (default: false)
    ->imageFlags()       // Force this specific column to use Image flags instead of Emojis

Phone Column

A basic text column pre-configured for phone numbers (monospaced).

use Nakanakaii\FilamentCountries\Tables\Columns\PhoneColumn;

PhoneColumn::make('phone_number')

Filters

Country Filter

A select filter to filter table data by country.

use Nakanakaii\FilamentCountries\Tables\Filters\CountryFilter;

CountryFilter::make('country_code')
    ->displayFlags(true) // Show or hide the flag in the dropdown options (default: true)
    ->emojiFlags()       // Force this specific filter to use Emoji flags instead of Images
```php
CountryFilter::make('country_code')
    ->displayFlags(false)

nakanakaii/filament-countries 适用场景与选型建议

nakanakaii/filament-countries 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.36k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 03 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 nakanakaii/filament-countries 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nakanakaii/filament-countries 我们能提供哪些服务?
定制开发 / 二次开发

基于 nakanakaii/filament-countries 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.36k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-02