hamedhaghi/countries 问题修复 & 功能扩展

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

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

hamedhaghi/countries

最新稳定版本:1.0.8

Composer 安装命令:

composer require hamedhaghi/countries

包简介

A PHP client for the RestCountries API

README 文档

README

A PHP client for the RestCountries API. This package simplifies interacting with the API by providing an object-oriented interface to retrieve country data.

Features

  • Fetch detailed information about countries.
  • Support for caching to improve performance.
  • Compatible with both legacy and modern PHP projects.

Requirements

  • PHP 7.0 or higher

Installation

Install the package via Composer:

composer require hamedhaghi/countries

Usage Example

require_once 'vendor/autoload.php';

use Hamed\Countries\Factory\CountryRepositoryFactory;

// Initialize the client
$factory = new CountryRepositoryFactory();

// Enable caching for faster responses (optional)
$factory = $factory->isCachable()
                   ->setCacheTTL(3600); // Cache expiration time in seconds

// Initialize the repository
$repository = $factory->init();

// Query country data
$countries = $repository->getAll();
$countries = $repository->getByCapital('Berlin');
$countries = $repository->getByCode('DE');
$countries = $repository->getByCurrency('euro');
$countries = $repository->getByDemonym('German');
$countries = $repository->getByFullName('Germany');
$countries = $repository->getByLanguage('German');
$countries = $repository->getByName('Germany');
$countries = $repository->getByRegion('Europe');
$countries = $repository->getBySubregion('Western Europe');
$countries = $repository->getByTranslation('Germany');

// Clear the cache
$factory->clearCache();

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License

This project is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-13