zguillez/php-tools

PHP模块,用于常见工具

v1.0.3 2020-11-12 12:14 UTC

This package is auto-updated.

Last update: 2024-09-12 20:46:32 UTC


README

Join the chat at https://gitter.im/zguillez/php-tools License

PHP模块,用于常见工具

入门

将包添加到composer.json

composer require zguillez/php-tools

//packaje.json
{
    "require": {
        "zguillez/php-tools": "^0.1.0"
    }
}

使用

require 'vendor/autoload.php';
use Z\Tools;

$tools = new Tools();
$tools->test('This is a test!');

示例

HTTP/GET

$data  = ['nombre' => 'test', 'apellidos' => 'test', 'email' => 'test@test.com'];
$result = $tools->get('https://dummy.webservice.com/json', $data, true);
$tools->test($result);

HTTP/POST

$data  = ['nombre' => 'test', 'apellidos' => 'test', 'email' => 'test@test.com'];
$result = $tools->post('https://dummy.webservice.com/json', $data, true);
$tools->test($result);

数据库

$db = $tools->database('***.***.***.***', 'user', '********', 'database');
$db->sql('INSERT INTO dummy_table SET value=1']);
leadid = $db->sql2lead('INSERT INTO dummy_table SET value=1']);
$tools->test($result);

EXCEL

$data = [[1, "a"], [2, "b"], [3, "c"], [4, "d"]];
$tools->excel('test', $data, ['id', 'value']);

数据库转EXCEL

$data = $tools->sql2array('SELECT * FROM dummy_table');
$tools->excel('test', $data, ['id', 'value', 'created_at'], true);
$tools->sql2csv('test', 'SELECT * FROM dummy_table', ['id', 'value', 'created_at']);
$tools->sql2excel('test2', 'SELECT * FROM dummy_table', ['id', 'value', 'created_at']);

贡献和问题

欢迎贡献者,请分支并提交拉取请求!如果您有任何改进此项目的想法,请提交问题或发送邮件

许可证

©2020 Zguillez.io

原始代码根据MIT许可证授权,本项目使用到的开源项目保留其原始许可证。

变更日志

v1.0.0 (2020年3月10日)

  • z-database包
  • z-http包

v0.1.0 (2017年5月31日)

  • GET/POST curl
  • 数据库连接
  • CSV/EXCEL文件导出

v0.0.1 (2017年5月10日)

  • 初始实现

Analytics