承接 alxmsl/network 相关项目开发

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

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

alxmsl/network

最新稳定版本:v1.1.2

Composer 安装命令:

composer require alxmsl/network

包简介

Simple library for network HTTP requests

README 文档

README

Native network requests driver for PHP

Installation

Require packet in a composer.json

"alxmsl/network": ">=1.0.0"

Run Composer: php composer.phar install

Usage example

// Firstly include base class
include('../source/Autoloader.php');

use Network\Http\Request;

// Create request object
$Request = new Request();
$Request->setUrl('http://topface.com')
    ->setConnectTimeout(3)
    ->setTimeout(5);

Now you need to select transport type. Today it supports only curl transport type, but if future will other types. For example, sockets

$Request->setTransport(Request::TRANSPORT_CURL);

Using curl transport, you can add any additional curl options

$Request->getTransport()->setOption(CURLOPT_FOLLOWLOCATION, true);

You can add url parameters for requests like a http://some.body/param1/value1/param2/value2

$Request->addUrlField('param1', 'value1')
    ->addUrlField('param2', 'value2');

You can add GET parameters

$Request->addGetField('param3', 'value3')
    ->addGetField('param4', 'value4');

You can add POST parameters

$Request->addPostField('field5', 'value5');
$Request->addPostField('field6', 'value6');

And send the request

$data = $Request->send();

License

Copyright © 2014 Alexey Maslov alexey.y.maslov@gmail.com This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: WTFPL
  • 更新时间: 2014-07-11