承接 human018/laravel-earth 相关项目开发

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

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

human018/laravel-earth

Composer 安装命令:

composer require human018/laravel-earth

包简介

A multilingual Laravel package to populate continents, countries, regions and cities for planet Earth

README 文档

README

Contributors Forks Stargazers Issues MIT License

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgements

About The Project

A multilingual Laravel package to populate continents, countries, regions, cities, languages and currencies for planet earth.

Built With

Getting Started

This project is built using Laravel 8 and is not currently backwards compatible with older versions.

Prerequisites

  • PHP 8.2
  • Laravel 10, 11 or 12
  • Guzzle
  • ZipArchive
  • Countrylayer API

Because this library uses an NPM package as one of it's data sources, you will need to allow composer to download an NPM package. To do so add the following property (or append to the already existing property) to the repositories array/object in your composer.json file.

    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ]

API Access

You will require an API key with countrylayer in order to use its services. A free key is available and all that will be required for the seed. Once you have your API key add it to your .env file.

COUNTRY_LAYER_API=XXX

Installation

  1. Using composer install the package to your project.

    composer require human018/laravel-earth
  2. Run database migration.

    php artisan migrate
  3. This package seeds the database with various sources (listed below) so an initialisation script need to be run in order to access these third-party sources and seed your database.

    php artisan earth:init
  4. (Optional) If you want to seed all the cities in a certain country pass in the country code. Note that this may take a long time depending on the country you're seeding.

    php artisan earth:init --country=au
  5. (Optional) You can also seed all major cities (over 15,000 in pop.).

    php artisan earth:init --cities=major

Usage

All models are located in the same namespace and can be imported into your local project.

use Human018\LaravelEarth\Models\Continent;
use Human018\LaravelEarth\Models\Country;
use Human018\LaravelEarth\Models\Region;
use Human018\LaravelEarth\Models\City;
use Human018\LaravelEarth\Models\Language;
use Human018\LaravelEarth\Models\Currency;
use Human018\LaravelEarth\Models\Timezone;
use Human018\LaravelEarth\Models\TimezoneUTC;

A couple of helpful methods for finding the correct resource are included. This means the resource name or code can be used to quickly locate a resource. Additionally, relationships between models are connected in a standard way and can be chained like usual.

// eg 1. Retrieve country by code 
$country = Country::code('au');
echo $country->regions->count();
// Returns '8'

// eg 2. You can pass in the Code in lower or upper case
$country = Country::code('AU');

// Eg 3. You can also search by name
$region = Region::name('New South Wales');
echo $region->country->name;
// Returns 'Australia'

echo $region->country->capital->name;
// Returns 'Canberra'

Retrieving timezones are slightly more complicated. Currently timezones are connected to Countries rather than Regions or Cities. Because a country can have multiple UTC zones, and in turn those zones can belong to the same Timezone, retrieving the relationship just requires us to use the unique query modifier.

$country = Country::code('ca'); // Canada
$country->timezones->pluck('label');
// Returns duplicates because it's unique UTC zones
// belong to many of the same Timezones

$country->timezones->unique()->pluck('label');
// Returns only unique timezones

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Simon Woodard - @human018

Project Link: https://github.com/Human018/laravel-earth

Acknowledgements

human018/laravel-earth 适用场景与选型建议

human018/laravel-earth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 501 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 11 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 human018/laravel-earth 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-26