Giter VIP home page Giter VIP logo

php-network's Introduction

Introduction

This is a PHP API for interfacing with the network

Installation

The easiest way to install is to use Composer. You can reference it in your project like this:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/FuturePublishing/php-network"
        }
    ],
    "require": {
        "FuturePublishing/php-network": ">=1.0.0"
    }
}

It conforms to the PSR-0 standard so can be autoloaded easily. (If you use Composer, including its autoloader.php will do all the work for you.)

Requirements

  • PHP 5.3+
  • PHPUnit 3.6+ (for running unit tests)

Usage

\Future\Network\Connection\SocketConnection

The SocketConnection class allows you to send data (it does not receive data) over a TCP or UDP connection. Example:

<?php
use \Future\Network\Connection\SocketConnection;

try {
    //                             host         port     protocol
    $socket = new SocketConnection('localhost', '11211', SocketConnection::TYPE_TCP);
    $socket->send("set / 0 3600 5 noreply\r\nhello\r\n");
} catch (\Future\Network\Exception $e) {
    die($e->getMessage());
}

The constructor will throw an exception if it fails to connect, meaning the class won't be instantiated. In this case you may want to instantiate a DummyConnection in its place if you need an object but you don't really care if it doesn't work.

\Future\Network\Connection\DummyConnection

The DummyConnection class implements the \Future\Network\Connection interface in the most minimal way possible. It is useful if you need to test with, or if a SocketConnection fails and you need something to pass to another class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.