Skip to content
boenrobot edited this page Aug 3, 2012 · 34 revisions

Getting started

Introduction

PHP has built in support for various types of network streams, such as HTTP and sockets. One problem that arises with them is the fact that a single fread/fwrite call might not read/write all the data you intended... regardless of whether you're in blocking mode or not. While the PHP manual offers a workaround in the form of a loop with a few variables, using it every single time you want to read/write can be tedious.

This package abstracts this away, so that when you want to get exactly N amount of bytes, you can be sure the upper levels of your app will be dealing with N bytes. Oh, and the functionality is nicely wrapped in an object (but that's just the icing on the cake).

Requirements

  • PHP 5.3.0 or later
  • [optional] PEAR2_Cache_SHM (bundled with the archive; needed only if you use persistent connections)

Installation

Installation with Pyrus/PEAR2 (recommended)

Assuming you have installed Pyrus, you can install PEAR2_Net_Transmitter from the pear2.php.net channel with

pyrus install PEAR2_Net_Transmitter-alpha

If you've decided to not use the pear2.php.net channel, but instead install directly from the archive distributed at the project page, you can use

pyrus install /path/to/downloaded/archive.tgz

Installation with PEAR

Like most PEAR2 packages, PEAR2_Net_Transmitter is compatible with the PEAR installer. However, you have to first discover the PEAR2 channel with

pear channel-discover pear2.php.net

and only then install PEAR2_Net_Transmitter with

pear install pear2/PEAR2_Net_Transmitter-alpha

Direct PHAR usage

If you download the ".phar" archive, instead of using the PEAR(2) installer, you can just include the archive, and be ready to go, like for example:

<?php
require_once 'PEAR2_Net_Transmitter-1.0.0a3.phar';
//Use any PEAR2_Net_Transmitter class

Manual installation

This package has no external dependencies, so you can just extract the contents of the "src" folder wherever you like. To emulate the PEAR2 installer, you can place the files in a folder that's within your include_path.

Troubleshooting

If the package doesn't work, you can download the "phar" file (maybe rename it from ".phar" to ".php"), and run it in your browser or command line.

When you do that, you should see the version of the package, along with some messages indicating if you're missing any of the requirements. If all requirements are present, you'll see suggestions as to what may go wrong when connecting to a host, and suggestions on how to fix it.

Clone this wiki locally