定制 phpuef/country 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

phpuef/country

最新稳定版本:v1.0.1

Composer 安装命令:

composer require phpuef/country

包简介

README 文档

README

Country

This package provides functions to search for country information (ISO 3166-1) based on their country codes (Alpha-2, Alpha-3, Numeric) and names. It is designed for easy integration into applications that need to work with country codes or names.

Static Badge

Packagist Downloads GitHub stars PHPStan Tests codecov

Versions

Stable Version GitHub Release GitHub Release

Also available in other languages

Go Implementation PHP Implementation

Installation

  composer require phpuef/country

Usage

Country Class Each country is represented by the Country class, which contains the following fields:

  • name: The country's name (in English).
  • alpha2: The two-letter country code (ISO 3166-1 alpha-2).
  • alpha3: The three-letter country code (ISO 3166-1 alpha-3).
  • numeric: The numeric country code (ISO 3166-1 numeric).

Functions

FindByAlpha2(string $alpha2): ?Country

This function searches for a country by its two-letter Alpha-2 code.

<?php

use Phpuef\Country\Countries;

class Example {

    public function findCZ() {
        $country = Countries::FindByAlpha2("CZ")
        if ($country !== null) {
            echo "Country Name: " + $country?->name;
            echo "Alpha-2 Code:: " + $country?->alpha2;
        }
    }
}

FindByAlpha3(string $alpha3): ?Country

This function searches for a country by its three-letter Alpha-3 code.

<?php

use Phpuef\Country\Countries;

class Example {

    public function findCZ() {
        $country = Countries::FindByAlpha3("CZE")
        if ($country !== null) {
            echo "Country Name: " + $country?->name;
            echo "Alpha-3 Code:: " + $country?->alpha3;
        }
    }
}

FindByName *Country

This function searches for a country by its name (english).

<?php

use Phpuef\Country\Countries;

class Example {

    public function findCZ() {
        $country = Countries::FindByName("Czechia")
        if ($country !== null) {
            echo "Country Name: " + $country?->name;
            echo "Alpha-2 Code:: " + $country?->alpha2;
            echo "Alpha-3 Code:: " + $country?->alpha3;
        }
    }
}

Contributing

Read Contributing

Contributors

JanGalek actions-user

Join our Discord Community! 🎉

Discord

Click above to join our community on Discord!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-18