承接 clicksend/integration-library-country-names 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

clicksend/integration-library-country-names

Composer 安装命令:

composer require clicksend/integration-library-country-names

包简介

Utility library to turn country names into ISO two-letter codes.

README 文档

README

This library is the PHP clone of the python library: alephdata/countrynames/

Requirements

  • PHP 7.0 and later.
  • Extensions: intl, yaml, mbstring, json.

Tested on PHP: 7.0, 7.2, 7.4, 8.1

Installation

Clone the git repo:

$ git clone https://github.com/ClickSend/integration-library-country-names.git

Example:

In your php file, paste this code.
Make sure to edit the integration-library-country-names directory to match your file structure.
Make sure the directory integration-library-country-names/lib/data is writable, for caching purpose.

<?php 

require_once 'integration-library-country-names/lib/CountryNames.php';

use CountryNamesLibrary\CountryNames;

var_dump('DE' == CountryNames::to_code('Germany'));
var_dump('DE' == CountryNames::to_code('Bundesrepublik Deutschland'));
var_dump('DE' == CountryNames::to_code('Bundesrepublik Deutschlan', $fuzzy=true));
var_dump('DE' == CountryNames::to_code('DE'));
var_dump('DEU' == CountryNames::to_code_3('Germany'));

you're all setup! To use the library as a composer package, see below.

To use it as a Composer Package:

First clone the repo to vendor directory in your project, then run composer autoload-dump command

$ git clone https://github.com/ClickSend/integration-library-country-names.git   your-project-path/vendor/integration-library-country-names
$ composer autoload-dump
<?php 

require_once 'vendor/autoload.php';

use CountryNamesLibrary\CountryNames;

var_dump('DE' == CountryNames::to_code('Germany'));
var_dump('DE' == CountryNames::to_code('Bundesrepublik Deutschland'));
var_dump('DE' == CountryNames::to_code('Bundesrepublik Deutschlan', $fuzzy=true));
var_dump('DE' == CountryNames::to_code('DE'));
var_dump('DEU' == CountryNames::to_code_3('Germany'));

Reloading data/deleting cache

If you updated the data.yaml file, then you need to delete the cache to reload the newly updated data, call this method once for every update:

CountryNames::_delete_cache();

Unit Test

To unit test run these commands, you need php version >= 7.3

composer install 

./vendor/bin/phpunit test

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-02-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固