gocanto/places-validation
Composer 安装命令:
composer require gocanto/places-validation
包简介
validate users addresses through services like google place
README 文档
README
Places validation is a laravel library that will help you out to handle your user addresses. Its aim is making sure the addresses submitted by users are valid through 3rd party services, as google.
Installation
Begin by installing the package through Composer. Run the following command in your terminal:
composer require gocanto/places-validation
Once composer is done, add the package service provider in the providers array in config/app.php:
Gocanto\AddressValidation\ValidatorServiceProvider::class
Client Side
Vuejs component which implements the google autocomplete library:
- Repository: https://github.com/gocanto/google-autocomplete
- Demo: https://gocanto.github.io/google-autocomplete/
Settings
You will be able to set the validator driver into config/addressval.php file. At the moment, the package just has the ability to work with google, but others services are planned ahead.
The array driver looks like this:
'driver' => [ //api key if required 'key' => '', //driver object 'name' => 'GeoogleGeocode', //api url 'api' => 'http://maps.google.com/maps/api/geocode/json' ],
if you do not set the driver within this file, the default one will be used.
Validate user address using the Laravel validator object
Now you will be able to use this package to validate the user address information within your validations rules. This is how it would look like:
$rules = [ 'address' => 'valid_place' ]; $data = [ 'address' => 'Guacara, Carabobo, Venezuela' ]; $v = \Validator::make($data, $rules);
You will be able to see the implementation on ManagerTest
Use out of the Laravel object
To implement the validation within your project, you have to include the Checker object as so:
use Gocanto\AddressValidation\Lib\Checker;
then, you can let laravel to handle the dependency injection for you, as so:
public function index(Checker $places) { if ( ! $v = $places->validate('Guacara, Carabobo, Venezuela')) { //the place is not valid. } //retrieve the place information. dd($v->retrieve(), $v->location()); }
Output Illustration
Inspiration
The inspiration came from a needed of using the validation within a form request object. I used Prosper Otemuyiwa package to have a scope of what I had to do.
Contributing
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
License
The MIT License (MIT). Please see License File for more information.
How can I thank you?
Why not star the github repo? Why not share the link for this repository on Twitter? Spread the word!
Don't forget to follow me on twitter!
Thanks!
Gustavo Ocanto. gustavoocanto@gmail.com
gocanto/places-validation 适用场景与选型建议
gocanto/places-validation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 260 次下载、GitHub Stars 达 47, 最近一次更新时间为 2016 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「validation」 「Users」 「validate」 「places」 「addresses」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gocanto/places-validation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gocanto/places-validation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gocanto/places-validation 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Runn Me! Validation and Sanitization Library
Debugging a problem and need to login as one of your customers? This allows you to authenticate as any of your customers.
Supercharged text field validation.
A trait for Laravel models which have many users with roles.
The library provides a flexible way to add role-based access control management to CakePHP 3.x
Integration bundle for Aura.Input with Aura.Filter
统计信息
- 总下载量: 260
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 47
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-08
