alexpts / php-transports
Any transports
0.1.0
2020-11-29 08:09 UTC
Requires
- php: ~8.0
- ext-mbstring: *
- ext-sockets: *
Requires (Dev)
- phpunit/phpunit: ^9.4
This package is auto-updated.
Last update: 2024-11-29 05:56:58 UTC
README
Install
composer require alexpts/php-transports
Support tcp
, udp
, file
, unix socket
transports
use PTS\Transport\File; use PTS\Transport\Tcp\TcpSocket; use PTS\Transport\Udp\UdpSocket; use PTS\Transport\UnixSocket; $udp = new UdpSocket; $udp->connect('127.0.0.1', ['port' => 3000]); $udp->write('some message'); $udp->close(); $unix = new UnixSocket; $unix->connect(__DIR__ . '/controller.sock'); $unix->write('some command'); $unix->close(); $tcp = new TcpSocket; $tcp->connect('127.0.0.1', ['port' => 3000]); $tcp->write('some message'); $tcp->close(); $file = new File; $file->connect(__DIR__ . '/log.txt', ['mode' => 'w+']); $file->write('some message'); $file->close();