承接 grithin/phpwebtools 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

grithin/phpwebtools

最新稳定版本:v1.0.0

Composer 安装命令:

composer require grithin/phpwebtools

包简介

PHP Curl, DOM, web data parsing tools.

README 文档

README

Curl

Basic curl class to handle the various curl function and avoid some common pitfalls of php curl (ex: post encoding being larger than browser post encoding).

Common Use

use \Grithin\Curl;

$curl = new Curl;

# can set headers either directly using 'options' or through instance attributes
$curl->options['CURLOPT_USERAGENT'] = 'harmless autobot';
$curl->user_agent = 'harmless autobot';

# can provide GET parameters as an array or as a string
$response = $curl->get('http://google.com/?s=bob');
$response = $curl->get('http://google.com/',['s'=>'bob']);


$response = $curl->post('http://google.com/',['s'=>'bob']);
$response = $curl->post('http://google.com/','s=bob');
$response = $curl->post('http://google.com/',json_encode(['bob'=>'s']));

File upload

Uses the old style, but works well enough

$response = $curl->post('http://thoughtpush.com/', ['s'=>'bob'], ['file1'=>'@'.__FILE__]);

Response Object

The Curl-send methods return a CurlReponse object with a headers array attribute and a body string attribute.

use \Grithin\Curl;

$curl = new Curl;
$response = $curl->get('http://thoughtpush.com');

\Grithin\Debug::out($response->headers);
/*
[base:index.php:14] 1: [
	'Http-Version' : '1.1'
	'Status-Code' : '200'
	'Status' : '200 OK'
	'Server' : 'nginx/1.4.6 (Ubuntu)'
	'Date' : 'Fri, 09 Oct 2015 19:36:01 GMT'
	...
*/
\Grithin\Debug::out($response->body);
/*
[base:index.php:15] 2: '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
	<head>
*/

Debugging

$curl->options[CURLOPT_VERBOSE] = true;

DomTools

Methods used for better handling of DOM and xpath.

Read the inline code comments

list($dom, $xpath) = DomTools::loadHtml($response->body);

WebData

Various web data methods including ones used to fulfill ASP validations by parsing responses and setting post parameters.

Read the inline code comments

统计信息

  • 总下载量: 38
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2015-10-09