定制 marshmallow/dataset-country 二次开发

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

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

marshmallow/dataset-country

Composer 安装命令:

composer require marshmallow/dataset-country

包简介

This dataset contains all the countries in the world. They are translateable in different languages. It is also possible to get the flag from said countries. The model is extendable so you can extend and overide all functionality if needed.

关键字:

README 文档

README

alt text

Marshmallow Dataset Country

Latest Version on Packagist Total Downloads

This dataset contains all the countries in the world. They are translateable in different languages. It is also possible to get the flag from said countries. The model is extendable so you can extend and override all functionality if needed.

Installation

Install the package via Composer:

composer require marshmallow/dataset-country

The service provider is auto-discovered and the package migrations are loaded automatically, so you only need to run your migrations:

php artisan migrate

This creates a countries table with name, slug, alpha2 and alpha3 columns (each unique).

Seed the table

Run the bundled seeder to fill the countries table:

php artisan db:seed --class="Marshmallow\Datasets\Country\Seeders\CountrySeeder"

Publish the flags

To use the flag images you need to publish them to your local project:

php artisan vendor:publish --provider="Marshmallow\Datasets\Country\ServiceProvider" --tag=public --force

You can optionally publish the translations as well:

php artisan vendor:publish --provider="Marshmallow\Datasets\Country\ServiceProvider" --tag=translations

Usage

The package ships an Eloquent model at Marshmallow\Datasets\Country\Models\Country.

use Marshmallow\Datasets\Country\Models\Country;

// Look up a country by its ISO alpha-2 code.
$country = Country::alpha2('nl');

// Get all countries ordered by name.
$countries = Country::ordered()->get();

Methods

  • Get the locale (translated) version of a country name with $country->getNameLocale().

Flags

You can get the flag of a country with $country->flag. If you wish to specify the size of the flag image, you can use $country->flag(16). The available sizes are 16, 24, 32, 48, 64 and 128 (the default is 32). Remember to publish the flags first (see Installation).

Traits

Add the Marshmallow\Datasets\Country\Traits\HasCountry trait to your models that have a country. This sets up the country() relationship:

use Marshmallow\Datasets\Country\Traits\HasCountry;

class Address extends Model
{
    use HasCountry;
}

// $address->country instanceof Country

Nova

Are you using Nova? We have a command for you to generate the Nova Resource. Run php artisan marshmallow:resource Country Datasets\\Country and countries will be available to you in Nova. We hide this resource by default in the Nova navigation. If you wish to have it available in the navigation, add public static $displayInNavigation = true; to app/Nova/Country.php.

Provinces, cities and airports

The model also exposes a provinces() relationship. This requires the optional marshmallow/dataset-google-geotargets package, which provides Google data on provinces, cities, airports etc.

composer require marshmallow/dataset-google-geotargets

Translations

The country names are translated into the following languages:

  • Arabic (ar)
  • Chinese (cn)
  • Czech (cs)
  • Danish (da)
  • German (de)
  • Greek (el)
  • English (en)
  • Spanish (es)
  • Estonian (et)
  • French (fr)
  • Hungarian (hu)
  • Italian (it)
  • Japanese (ja)
  • Lithuanian (lt)
  • Dutch (nl)
  • Norwegian (no)
  • Polish (pl)
  • Portuguese (pt)
  • Romanian (ro)
  • Russian (ru)
  • Slovak (sk)
  • Thai (th)
  • Ukrainian (uk)

Security Vulnerabilities

Please report security vulnerabilities by email to stef@marshmallow.dev rather than via the public issue tracker.

Credits

License

The MIT License (MIT). Please see the License File for more information.

Copyright (c) 2020 marshmallow

marshmallow/dataset-country 适用场景与选型建议

marshmallow/dataset-country 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.98k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 04 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「marshmallow」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 marshmallow/dataset-country 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-07