Download the PHP package initphp/socket without Composer

On this page you can find all versions of the php package initphp/socket. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package socket

initphp/socket

Latest Stable Version Total Downloads License PHP Version Require CI

A lightweight TCP, UDP, TLS and SSL socket toolkit for PHP 8.1+. Both server and client sides share a clean, typed API built around enums and a small Channel strategy so each transport plugs in without switch ladders.

Requirements

Installation

Features

Quick start

TCP echo server

TCP client

TLS server (chat-style with named clients)

SSL client (talking to Gmail SMTP)

API surface

Factory — InitPHP\Socket\Socket

Servers — InitPHP\Socket\Interfaces\SocketServerInterface

Method Purpose
listen(): static Bind and start listening. Does not accept clients.
live(callable $cb, float $idle = 0.05): void Run the accept/dispatch loop until stop() is called.
tick(callable $cb, float $wait = 0.0): int One iteration of the loop. Returns events processed.
stop(): void Cooperatively exit the loop started by live().
close(): bool Tear everything down (every client + the listening socket).
broadcast(string $msg, int\|string\|array\|null $ids = null): bool Send to all clients or a targeted subset.
register(int\|string $id, SocketConnectionInterface $conn): bool Attach an addressable id to a connection.
getClients(): array Map of id|key → connection.

AbstractStreamServer (TLS / SSL) additionally exposes:

Clients — InitPHP\Socket\Interfaces\SocketClientInterface

Method Purpose
connect(): static Open the connection.
disconnect(): bool Close the connection. Idempotent.
read(int $len = 1024): ?string Receive up to $len bytes. Returns null on no data / failure.
write(string $data): ?int Send $data. Returns the number of bytes written, or null on failure.

AbstractStreamClient (TLS / SSL) adds option(), timeout(), blocking() and crypto() — same shape as the server side.

Enums

Exceptions

Every package exception implements SocketExceptionInterface, so a single catch (SocketExceptionInterface $e) covers them all.

Embedding into your own event loop

If you already run an event loop (ReactPHP, Amp, Swoole-bridge, etc.), do not call live() — invoke tick() from your loop and let the host decide when to yield:

Documentation

In-depth guides live under docs/:

Development

CI runs the full QA pipeline on PHP 8.1, 8.2 and 8.3.

Contributing

Issues, ideas and pull requests are welcome. Please read the org-wide contributing guide before opening a PR.

Security issues should be reported privately — see SECURITY.md.

Credits

License

Released under the MIT License.


All versions of socket with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-sockets Version *
ext-openssl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package initphp/socket contains the following files

Loading the files please wait ...