pragmarx/countries-laravel
Composer 安装命令:
composer require pragmarx/countries-laravel
包简介
Countries for Laravel
关键字:
README 文档
README
Countries for Laravel
What does it gives you?
This package has all sorts of information about countries:
| info | items |
|---|---|
| taxes | 32 |
| geometry maps | 248 |
| topology maps | 248 |
| currencies | 256 |
| countries | 266 |
| timezones | 423 |
| borders | 649 |
| flags | 1,570 |
| states | 4,526 |
| cities | 7,376 |
| timezones times | 81,153 |
Validation
The validation is extending Laravel's validation, so you can use it like any other validation rules, like
/** * Store a new blog post. * * @param Request $request * @return Response */ public function store(Request $request) { $this->validate($request, [ 'title' => 'required|unique:posts|max:255', 'body' => 'required', 'country' => 'country' //Checks if valid name.common ]); // The blog post is valid, store in database... }
Which validation rules there is and what there name should be, can all be configured in the configuration file.
'validation' => [ 'rules' => [ 'countryCommon' => 'name.common' ] ]
By changing the configuration like this, we can now access the property name.common, by the validation rule countryCommon
You have to define all the validations rules in settings, only a few is defined by default, the default is
'rules' => [ 'country' => 'name.common', 'cca2', 'cca3', 'ccn3', 'cioc', 'currencies' => 'ISO4217', 'language', 'language_short' => 'ISO639_3', ]
Documentation
This package is a Laravel bridge, please refer to the main package repository for more information and docs.
Requirements
- PHP 7.0+
- Laravel 5.5+
Installing
Use Composer to install it:
composer require pragmarx/countries-laravel
Publishing assets
You can publish configuration by doing:
php artisan vendor:publish --provider=PragmaRX\\CountriesLaravel\\Package\\ServiceProvider
Usage
After installing you'll have access to the Countries Façade, and the package is based on Laravel Collections, so you basically have access to all methods in Collections, like
$france = Countries::where('name.common', 'France');
Flag routes
You can refer directly to an SVG flag by linking
/pragmarx/countries/flag/download/<cca3-code>.svg
/pragmarx/countries/flag/file/<cca3-code>.svg
Examples:
https://laravel.com/pragmarx/countries/flag/download/usa.svg
https://laravel.com/pragmarx/countries/flag/file/usa.svg
http://pragmarx.test/pragmarx/countries/flag/file/usa.svg
These routes can be turned off in the configuration file:
'routes' => [ 'enabled' => false, ]
Author
License
Countries is licensed under the MIT License - see the LICENSE file for details
Contributing
Pull requests and issues are more than welcome.
pragmarx/countries-laravel 适用场景与选型建议
pragmarx/countries-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.07M 次下载、GitHub Stars 达 147, 最近一次更新时间为 2018 年 01 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「geometry」 「flag」 「laravel」 「states」 「countries」 「taxes」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pragmarx/countries-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pragmarx/countries-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pragmarx/countries-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Cold template caches that can be flagged and automatically invalidated.
Laravel Eloquent boolean & timestamp flagged attributes behavior.
Bitwise flag setting for Yii 2.x
Country Flag Emoji for PHP
Add country flags attribute to Flarum Users
Geo-related tools PHP 7.3+ library
统计信息
- 总下载量: 1.07M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 149
- 点击次数: 31
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2018-01-24
