1 Star 0 Fork 0

小马哥 / php-utils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

简介

php 一些常用的扩展

自动化测试

项目跟目录下执行

./vendor/bin/phpunit

类说明

BrowserAgent.php

use magein\utils\BrowserAgent;
BrowserAgent::random();
BrowserAgent::android();
// 返回一个数组包含user-agent参数
BrowserAgent::header();

Validator.php

常用的验证类

use magein\utils\Validator;

Validator::phone();
Validator::email();
Validator::qq();
Validator::idCard();
Validator::url();
Validator::http();
Validator::https();
Validator::ip();
Validator::ipv4();
Validator::ipv6();
Validator::image();
Validator::chinese();

Result.php

用于方法的返回值

Faker.php

用于生成数据

use magein\utils\Faker;
Faker::email();
Faker::phone();
Faker::text();
Faker::phone();
Faker::name();
Faker::title();

Location.php

规范经纬度取值,仅仅是规范不同地图取值经纬度前后的问题,腾讯地址返回维度在前,高德返回经度在前

仅仅适用与中国范围内的经纬度

use magein\utils\Location;

$number = '39.5420,116.2529';
$location = Location::init($number);
// 经度在前的字符串
$location->toString();
$location->toArray();
// 返回带键的数组通过 longitude和latitude
$location->toArray(false);
// 获取经度
$location->getLongitude();
// 获取维度
$location->getLatitude();

Http.php

使用需要安装GuzzleHttp

composer require guzzlehttp/guzzle:^7.6
use magein\utils\Location;

$http = new \magein\utils\Http;
// 要添加到请求的查询字符串的关联数组或查询字符串
$http->get($url,$params=[]);
// 用来发送一个 application/x-www-form-urlencoded POST请求
$http->formParams($url,$params);
// 设置请求的主体为 multipart/form-data 表单 
$http->multipartFormData($url,$params);
$http->json($url,$params,'post');
$http->body($url,$params,'put');

Tree.php


use magein\utils\Location;

$tree = new \magein\utils\Tree($data);
$data=$tree->transfer();

// 设置主键ID
$tree->setPrimary('id');
// 设置父级索引 默认parent_id
$tree->setParentId('pid');
// 设置子集索引 默认child
$tree->setChild('children');

// 数据结构转化成一维数组
$tree->floor($url,$params);
// 设置请求的主体为 multipart/form-data 表单

更新日志

v2.0.0

2024-02-29

  1. 更新目录以及命名空间规范,目录名称小写

v1.0.7

2024-02-26

  1. 增加DataSecurity.php 数据加密(可逆)

v1.0.6

2024-02-24

  1. 修改ClientIp.php名称为Client.php
  2. Client.php增加isWin和isLinux判断客户端的操作

v1.0.5

2024-01-27

  1. 增加Tree类,将数据转化成树结构

v1.0.4

  1. 增加http类 对GuzzleHttp重新进行了封装

v1.0.3

  1. Result.php修改auto方法

v1.0.2

  1. Result.php新增auto方法
  2. 新增BrowserAgent.php
  3. 新增phpunit单元测试
  4. 优化Validator.php的代码
  5. 优化Image.php,保存图片支持base64和远程获取
MIT License Copyright (c) 2023 小马哥 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

php开发使用的工具类 不依赖框架 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/magein/php-utils.git
git@gitee.com:magein/php-utils.git
magein
php-utils
php-utils
master

搜索帮助