chendujin/mobile
最新稳定版本:v1.1.0
Composer 安装命令:
composer require chendujin/mobile
包简介
PHP版本的中国手机号码归属地查询
README 文档
README
- 使用 https://github.com/xluohome/phonedata 提供的数据库
环境需求
- php >= 7.0
- Composer
安装
composer require chendujin/mobile
配置
Laravel环境无需配置
Lumen
将下面代码放入 bootstrap/app.php
$app->register(Chendujin\Mobile\ServiceProvider::class);
验证器使用
<?php public function store(Request $request) { $validator = Validator::make($request->all(), [ 'phone' => 'required|is_cmcc|is_cucc|is_ctcc|is_ctccv|is_cuccv|is_cmccv|is_cbcc|is_cbccv' ]); if ($validator->fails()) { return new JsonResponse([ 'state' => 'error', 'message' => $validator->errors()->first(), ]); } }
其他使用
$mobile = new \Chendujin\Mobile\Mobile(); // 查询 $mobile->search('15240881243'); // 是否是移动运营商 $mobile->isCMCC('18807397135'); // true // 是否是联通运营商 $mobile->isCUCC('15507645084'); // true // 是否是电信运营商 $mobile->isCTCC('18923516448'); // true // 是否是广电运营商 $mobile->isCBCC('19212071413'); // true // 是否为手机号码 $mobile->isMobilePhone('18923516448'); // true // 判断是否为座机号码 $mobile->isTelPhone('5957126'); // true
命令行工具
php bin/searchMobile 15240881243
返回:
Array
(
[mobile] => 15240881243
[province] => 云南
[city] => 昭通
[zip_code] => 657000
[area_code] => 0870
[operator_type] => 移动
)
time: 0.0093469620 s
memory:664 B
单元测试
./vendor/bin/phpunit
统计信息
- 总下载量: 137
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-07