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.0and 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
其他信息
- 授权协议: Unknown
- 更新时间: 2022-02-25