Need help with php-uv?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

bwoebi
143 Stars 23 Forks Other 676 Commits 16 Opened issues

Services available

!
?

Need anything else?

Contributors list

No Data

php-uv

Build Status

Interface to libuv for php.

Install

*nix

git clone https://github.com/bwoebi/php-uv.git
cd php-uv
phpize
./configure
make
make install
# add `extension=uv.so` to your php.ini

Windows

Windows builds for stable PHP versions are available from PECL.

Examples

see examples and tests directory.

uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',8888));

uv_listen($tcp,100, function($server){ $client = uv_tcp_init(); uv_accept($server, $client); var_dump(uv_tcp_getsockname($server));

uv_read_start($client, function($socket, $nread, $buffer){
    var_dump($buffer);
    uv_close($socket);
});

});

$c = uv_tcp_init(); uv_tcp_connect($c, uv_ip4_addr('0.0.0.0',8888), function($stream, $stat){ if ($stat == 0) { uv_write($stream,"Hello",function($stream, $stat){ uv_close($stream); }); } });

uv_run();

Original Author

  • Shuhei Tanuma

Current Maintainer

  • Bob Weinand

License

PHP License

Documents

void uvunref(resource $uvt)

Description

decrement reference

Parameters

resource $uv_t: uv resource handle.

Return Value

*void *:

Example

long uvlasterror([resource $uv_loop])

Description

get last error code.

Parameters

resource $uv_loop: uv loop handle

Return Value

long $error_code: error code

Example

string uverrname(long $error_code)

Description

get error code name.

Parameters

long $error_code: libuv error code

Return Value

string $erorr_name: error name

Example

string uvstrerror(long $errorcode)

Description

get error message.

Parameters

long $error_code: libuv error code

Return Value

string $erorr_message: error message

Example

void uvupdatetime(resource $uv_loop)

void uvref(resource $uvhandle)

Description

increment reference count

Parameters

resource $uv_handle: uv resource.

Return Value

void:

Example
TODO

  • support uv_loop resource

void uvrun([resource $uvloop])

Description

run event loop

Parameters

resource $uv_loopg: uv_loop resource

Return Value

void:

Example
uv_async_send($async);

uv_run();

void uvrunonce([resource $uv_loop])

void uvloopdelete(resource $uv_loop)

Description

delete specified loop resource.

Parameters

resource $uv_loop: uv_loop resource

Return Value

void:

Example

long uvnow(resource $uvloop)

void uvtcpbind(resource $uvtcp, resource $uvsockaddr)

Description

binds a name to a socket.

Parameters

resource $uv_tcp: uv_tcp resource

resource $uv_sockaddr: uv sockaddr4 resource.

Return Value

void:

Example
uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999));

uv_listen($tcp,100, function($server){ $client = uv_tcp_init(); uv_accept($server, $client); var_dump(uv_tcp_getsockname($server));

uv_read_start($client, function($socket, $nread, $buffer) use ($server){
    var_dump($buffer);
    uv_close($socket);
    uv_close($server);
});

});

void uvtcpbind6(resource $uvtcp, resource $uvsockaddr)

Description

binds a name to a socket.

Parameters

resource $uv_tcp: uv_tcp resource

resource $uv_sockaddr: uv sockaddr6 resource.

Return Value

void:

Example
uv_listen($tcp,100, function($server){
    $client = uv_tcp_init();
    uv_accept($server, $client);
    var_dump(uv_tcp_getsockname($server));

uv_read_start($client, function($socket, $nread, $buffer) use ($server){
    var_dump($buffer);
    uv_close($socket);
    uv_close($server);
});

});

void uv_write(resource $handle, string $data, callable $callback)

Description

send buffer to speicified uv resource.

Parameters

resource $handle: uv resources (uvtcp, uvudp, uv_pipe ...etc.) string $data: buffer. callable $callback: callable variables. this callback expects (resource $handle, long $status)

Return Value

void:

Example

void uv_write2(resource $handle, string $data, resource $send, callable $callback)

void uvtcpnodelay(resource $handle, bool $enable)

Description

set Nagel's flags for specified tcp resource.

Parameters

resource $handle: libuv tcp resource

bool $enable: true means enabled. false means disabled.

Return Value

void:

Example

void uv_accept(resource $server, resource $client)

Description

accepts a connection on a socket.

Parameters

resource $uv: uvtcp or uvpipe server resource

resource $uv: uvtcp or uvpipe client resource.

Return Value

void:

Example
uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999));

uv_listen($tcp,100, function($server){ $client = uv_tcp_init(); uv_accept($server, $client); var_dump(uv_tcp_getsockname($server));

uv_read_start($client, function($socket, $nread, $buffer) use ($server){
    var_dump($buffer);
    uv_close($socket);
    uv_close($server);
});

});

void uv_shutdown(resource $handle, callable $callback)

Description

shutdown uv handle.

Parameters

resource $handle: uv resources (uvtcp, uvudp, uv_pipe ...etc.) callable $callback: callable variables. this callback expects (resource $handle, long $status)

Return Value

void:

Example

void uv_close(resource $handle, callable $callback)

Description

close uv handle.

Parameters

resource $handle: uv resources (uvtcp, uvudp, uv_pipe ...etc.) callable $callback: callable variables. this callback expects (resource $handle, long $status)

Return Value

void:

Example

void uvreadstart(resource $handle, callable $callback)

Description

starts read callback for uv resources.

Parameters

resource $handle: uv resources (uvtcp, uvudp, uv_pipe ...etc.)

callable $callback: callable variables. this callback parameter expects (resource $handle, long $nread, string buffer)

Return Value

void:

Example
Note

  • You have to handle erorrs correctly. otherwise this will leak.
  • if you want to use PHP's stream or socket resource. see uvfspollinit and uvfs_read.

void uvread2start(resource $handle, callable $callback)

void uvreadstop(resource $handle)

Description

stop read callback

Parameters

resource $uv: uv resource handle which started uv_read.

Return Value

void:

Example
uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999));

uv_listen($tcp,100, function($server){ $client = uv_tcp_init(); uv_accept($server, $client); var_dump(uv_tcp_getsockname($server));

uv_read_start($client, function($socket, $nread, $buffer) use ($server){
    uv_read_stop($socket);
    var_dump($buffer);
    uv_close($socket);
    uv_close($server);
});

});

resource uvip4addr(string $ipv4_addr, long $port)

Description

create a ipv4 sockaddr.

Parameters

string $ipv4_addr: ipv4 address

long $port: port number.

Return Value

resource $uv_sockaddr: sockaddr resource

Example
Todo

  • check passed ip address is valid.
  • check port number is valid

resource uvip6addr(string $ipv6_addr, long $port)

Description

create a ipv6 sockaddr.

Parameters

string $ipv6_addr: ipv6 address

long $port: port number.

Return Value

resource $uv_sockaddr: sockaddr resource

Example
Todo

  • check passed ip address is valid.
  • check port number is valid

void uv_listen(resource $handle, long $backlog, callable $callback)

Description

listens for a connection on a uv handle.

Parameters

resource $handle: uv resource handle (tcp, udp and pipe)

long $backlog: backlog

callable $callback: this callback parameter expects (resource $connection, long $status)

Return Value

*void *:

Example
uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',9999));

uv_listen($tcp,100, function($server, $status){ $client = uv_tcp_init(); uv_accept($server, $client); uv_read_start($client, function($socket, $nread, $buffer) use ($server){ var_dump($buffer); uv_close($socket); uv_close($server); }); }); uv_run();

void uvtcpconnect(resource $handle, resource $ipv4_addr, callable $callback)

Description

connect to specified ip address and port.

Parameters

resource $handle: requires

uv_tcp_init()
resource. resource $ipv4_addr: requires uv_sockaddr resource. callable $callback: callable variables.
Return Value

void:

Example
uv_run();

void uvtcpconnect6(resource $handle, resource $ipv6_addr, callable $callback)

Description

connect to specified ip address and port.

Parameters

resource $handle: requires

uv_tcp_init()
resource. resource $ipv4_addr: requires uv_sockaddr resource. callable $callback: callable variables.
Return Value

void:

Example
uv_run();

resource uvtimerinit([resource $loop])

Description

initialize timer handle.

Parameters

resource $loop: uv_loop resource.

Return Value

resource $timer: initialized timer resource.

Example

void uvtimerstart(resource $timer, long $timeout, long $repeat, callable $callback)

Description

initialize timer handle.

Parameters

resource $loop: uv_loop resource.

long $timeout: periodical event starts when after this timeout. 1000 is 1 sec.

long $repeat: repeat interval. 1000 is 1 sec.

Return Value

*void:

Example
uv_run();

void uvtimerstop(resource $timer)

Description

stop specified timer.

Parameters

resource $timer: uv timer resource.

Return Value

long $retval:

Example
uv_run();

void uvtimeragain(resource $timer)

Description

restart timer.

Parameters

resource $timer: uv_timer resource.

Return Value

void:

Example

void uvtimerset_repeat(resource $timer, long $repeat)

Description

set repeat count.

Parameters

resource $uv_timer: uv_timer resource

long $repeat: repeat count

Return Value

void:

Example

long uvtimerget_repeat(resource $timer)

Description

returns repeat interval.

Parameters

resource $uv_timer: uv_timer resource

Return Value

long $repeat_time:

Example

resource uvidleinit([resource $loop])

Description

initialize uv idle handle.

Parameters

resource $loop: uv_loop resource.

Return Value

resource $idle: initialized idle handle.

Example

void uvidlestart(resource $idle, callable $callback)

Description

start idle callback.

Parameters

resource $idle: uv_idle resource. callable $callback: idle callback.

Return Value

long result:

Example
$i = 0;
uv_idle_start($idle, function($idle_handle, $stat) use (&$i){
    echo "count: {$i}" . PHP_EOL;
    $i++;

if ($i > 3) {
    uv_idle_stop($idle);
}
sleep(1);

});

uv_run();

void uvidlestop(resource $idle)

Description

stop idle callback.

Parameters

resource $idle: uv_idle resource.

Return Value

long result:

Example
$i = 0;
uv_idle_start($idle, function($idle_handle, $stat) use (&$i){
    echo "count: {$i}" . PHP_EOL;
    $i++;

if ($i > 3) {
    uv_idle_stop($idle);
}
sleep(1);

});

uv_run();

void uv_getaddrinfo(resource $loop, callable $callback, string $node, string $service, array $hints)

resource uvtcpinit([resource $loop])

Description

create a tcp socket.

Parameters

resource $loop: loop resource or null. if not specified loop resource then use uvdefaultloop resource.

Return Value

resource php_uv: uv resource which initialized for tcp.

Example

resource uvdefaultloop()

Description

return default loop handle.

Parameters
Return Value

resource $loop:

Example

resource uvloopnew()

Description

create a new loop handle.

Parameters
Return Value

resource $loop:

Example

resource uvudpinit([resource $loop])

Description

create a udp socket.

Parameters

resource $loop: loop resource or null. if not specified loop resource then use uvdefaultloop resource.

Return Value

resource php_uv: uv resource which initialized for udp.

Example

void uvudpbind(resource $resource, resource $address, long $flags)

Description

listens for a connection on a uv udp handle.

Parameters

resource $handle: uv resource handle (udp)

resource $uvipaddr: uv sockaddr(ipv4) resource.

long $flags: unused.

Return Value

*void *:

Example
uv_udp_bind($udp, uv_ip4_addr('0.0.0.0',10000));

uv_udp_recv_start($udp,function($stream, $nread, $buffer){ echo "recv:" . $buffer;

uv_close($stream);

});

$uv = uv_udp_init(); uv_udp_send($uv, "Hello", uv_ip4_addr("0.0.0.0",10000),function($uv, $s){ echo "success" . PHP_EOL; uv_close($uv); });

uv_run();

void uvudpbind6(resource $resource, resource $address, long $flags)

Description

listens for a connection on a uv udp handle.

Parameters

resource $handle: uv resource handle (udp)

resource $uvipaddr: uv sockaddr(ipv6) resource.

long $flags: Should be 0 or UV::UDP_IPV6ONLY

Return Value

*void *:

Example
uv_udp_bind6($udp, uv_ip6_addr('::1',10000));

uv_udp_recv_start($udp,function($stream, $nread, $buffer){ echo "recv:" . $buffer;

uv_close($stream);

});

$uv = uv_udp_init(); uv_udp_send6($uv, "Hello", uv_ip6_addr("::1",10000),function($uv, $s){ echo "success" . PHP_EOL; uv_close($uv); });

uv_run();

void uvudprecv_start(resource $handle, callable $callback)

Description

start receive callback.

Parameters

resource $handle: uv resource handle (udp)

callable $callback: this callback parameter expects (resource $stream, long $nread, string $buffer).

Return Value

*void *:

Example
uv_udp_bind6($udp, uv_ip6_addr('::1',10000));

uv_udp_recv_start($udp,function($stream, $nread, $buffer){ echo "recv:" . $buffer;

uv_close($stream);

});

$uv = uv_udp_init(); uv_udp_send6($uv, "Hello", uv_ip6_addr("::1",10000),function($uv, $s){ echo "success" . PHP_EOL; uv_close($uv); });

uv_run();

void uvudprecv_stop(resource $handle)

Description

stop receive callback.

Parameters

resource $handle: uv resource handle (udp)

Return Value

*void *:

long uvudpsetmembership(resource $handle, string $multicastaddr, string $interface_addr, long $membership)

Description

join or leave udp muticast group..

Parameters

resource $handle: uv resource handle (udp)

string $multicast_addr: multicast address

string $interface_addr: interface address

long $membership: UV::JOINGROUP or UV::LEAVEGROUP

Return Value

*long *: result code

Example

void uvudpsetmulticastloop(resource $handle, long $enabled)

Description

set multicast loop

Parameters

resource $handle: uv resource handle (udp)

long $enabled:

Return Value

void:

Example

void uvudpsetmulticastttl(resource $handle, long $ttl)

Description

set multicast ttl

Parameters

resource $handle: uv resource handle (udp)

long $ttl: multicast ttl

Return Value

void:

Example

void uvudpset_broadcast(resource $handle, bool $enabled)

Description

set udp broadcast

Parameters

resource $handle: uv resource handle (udp)

long $enabled:

Return Value

void:

Example

void uvudpsend(resource $handle, string $data, resource $uv_addr, callable $callback)

Description

send buffer to specified address.

Parameters

resource $handle: uv resource handle (udp)

string $data: data

resource uv_addr: uvip4addr

callable $callback: this callback parameter expects (resource $stream, long $status).

Return Value

*void *:

Example
uv_udp_bind($udp, uv_ip4_addr('::1',10000));

uv_udp_recv_start($udp,function($stream, $nread, $buffer){ echo "recv:" . $buffer;

uv_close($stream);

});

$uv = uv_udp_init(); uv_udp_send($uv, "Hello", uv_ip4_addr("::1",10000),function($uv, $s){ echo "success" . PHP_EOL; uv_close($uv); });

uv_run();

void uvudpsend6(resource $handle, string $data, resource $uv_addr6, callable $callback)

Description

send buffer to specified address.

Parameters

resource $handle: uv resource handle (udp)

string $data: data

resource uv_addr: uvip6addr

callable $callback: this callback parameter expects (resource $stream, long $status).

Return Value

*void *:

Example
uv_udp_bind6($udp, uv_ip6_addr('::1',10000));

uv_udp_recv_start($udp,function($stream, $nread, $buffer){ echo "recv:" . $buffer;

uv_close($stream);

});

$uv = uv_udp_init(); uv_udp_send6($uv, "Hello", uv_ip6_addr("::1",10000),function($uv, $s){ echo "success" . PHP_EOL; uv_close($uv); });

uv_run();

bool uvisactive(resource $handle)

bool uvisreadable(resource $handle)

bool uviswritable(resource $handle)

bool uv_walk(resource $loop, callable $closure[, array $opaque])

TODO

  • implement this.

long uvguesshandle(resource $uv)

long uvhandletype(resource $uv)

Description

returns current uv type. (this is not libuv function. util for php-uv)

Parameters

resource $uv_handle: uv_handle

Return Value

long $handle_type: should return UV::ISUV* constatns. e.g) UV::ISUVTCP

Example
Note

  • this may change.

resource uvpipeinit(resource $loop, long $ipc)

Description

initialize pipe resource

Parameters

resource $uv_loop: uv_loop resource

bool $ipc: when this pipe use for ipc, please set true otherwise false.

Return Value

resource $uv_pipe:

Example

void uvpipeopen(resource $handle, long $pipe)

Description

open a pipe resource.

Parameters

resource $uv_handle: uv pipe handle

*long $pipe: dunnno. maybe file descriptor.

Return Value

void:

Example

long uvpipebind(resource $handle, string $name)

Description

create a named pipe.

Parameters

resource $uv_handle: uv pipe handle

*long $pipe: dunnno. maybe file descriptor.

Return Value

void:

Example

void uvpipeconnect(resource $handle, string $path, callable $callback)

Description

connect to named pipe.

Parameters

resource $uv_handle: uv pipe handle

*string $path: named pipe path

*callable $callback: this callback parameter expects (resource $pipe, long $status)

Return Value

void:

Example
uv_run();

void uvpipepending_instances(resource $handle, long $count)

resource uvaresinit_options(resource $loop, array $options, long $optmask)

void ares_gethostbyname(resource $handle, string $name, long $flag, callable $callback)

array uv_loadavg(void)

Description

retunrs current loadaverage.

Parameters
Return Value

array $loadaverage:

Example
//  float(1.7421875)
//  [1]=>
//  float(1.427734375)
//  [2]=>
//  float(1.3955078125)
//}
Note

returns array on windows box. (does not support load average on windows)

double uv_uptime(void)

Description

returns current uptime.

Parameters
Return Value

long $uptime:

Example

long uvgetfree_memory(void)

Description

returns current free memory size.

Parameters
Return Value

long $free:

Example

long uvgettotal_memory(void)

Description

returns total memory size.

Parameters
Return Value

long $free:

Example

long uv_hrtime(void)

TODO

check implmentation

string uv_exepath(void)

Description

returns current exepath. basically this will returns current php path.

Parameters
Return Value

string $exepath:

Example

string uv_cwd(void)

Description

returns current working directory.

Parameters
Return Value

string $cwd:

Example

array uvcpuinfo(void)

Description

returns current cpu informations

.

Parameters
Return Value

array $cpu_info:

Example
//  array(3) {
//    ["model"]=>
//    string(13) "MacBookPro8,2"
//    ["speed"]=>
//    int(2200)
//    ["times"]=>
//    array(5) {
//      ["sys"]=>
//      int(69952140)
//      ["user"]=>
//      int(38153450)
//      ["idle"]=>
//      int(776709120)
//      ["irq"]=>
//      int(0)
//      ["nice"]=>
//      int(0)
//    }
//  }...

array uvinterfaceaddresses(void)

resource uvstdionew(zval $fd, long $flags)

resource uv_spawn(resource $loop, string $command, array $args, array $stdio, string $cwd, array $env = array(), callable $callback [,long $flags, array $options])

void uvprocesskill(resource $handle, long $signal)

Description

send signal to specified uv process resource.

Parameters

resource $handle: uv resource handle (process)

long $signal:

Return Value

void:

Example

void uv_kill(long $pid, long $signal)

Description

send signal to specified pid.

Parameters

long $pid: process id

long $signal:

Return Value

void:

Example

bool uv_chdir(string $directory)

Description

change working directory.

Parameters

string $directory:

Return Value

*bool *:

Example

resource uvrwlockinit(void)

Description

initialize rwlock resource

Parameters
Return Value

resource $rwlock: returns uv rwlock resource

Example

uvrwlockrdlock(resource $handle)

Description

set read lock

Parameters

resource $handle: uv resource handle (uv rwlock)

Return Value

*void *:

Example

bool uvrwlocktryrdlock(resource $handle)

TODO

  • implemnt this correctly

void uvrwlockrdunlock(resource $handle)

Description

unlock read lock

Parameters

resource $handle: uv resource handle (uv rwlock)

Return Value

void:

Example

uvrwlockwrlock(resource $handle)

Description

set write lock

Parameters

resource $handle: uv resource handle (uv rwlock)

Return Value

*void *:

Example

uvrwlocktrywrlock(resource $handle)

TODO
  • implement this correctly

uvrwlockwrunlock(resource $handle)

Description

unlock write lock

Parameters

resource $handle: uv resource handle (uv rwlock)

Return Value

void:

Example

uvlock uvmutex_init(void)

Description

initialize mutex resource

Parameters
Return Value

resource $uv_mutex: uv mutex resource

Example

void uvmutexlock(uv_lock $lock)

Description

lock mutex

Parameters

resource $handle: uv resource handle (uv mutex)

Return Value

void:

Example

bool uvmutextrylock(uv_lock $lock)

TODO
  • implement this correctly

uvlock uvsem_init(long $value)

Description

initialize semaphore resource

Parameters
Return Value

resource $uv_sem:

Example

void uvsempost(uv_lock $sem)

Description

post semaphore

Parameters

resource $handle: uv resource handle (uv sem)

Return Value

void:

Example

void uvsemwait(uv_lock $sem)

Todo
  • implemnt this correctly

void uvsemtrywait(uv_lock $sem)

Todo
  • implment this correctly

resource uvprepareinit(resource $loop)

Description

initialize prepare resource

Parameters

resource $loop: uv loop handle

Return Value

resource $uv_prepare:

Example

void uvpreparestart(resource $handle, callable $callback)

Description

setup prepare loop callback. (pre loop callback)

Parameters

resource $handle: uv resource handle (prepare)

callable $callback: this callback parameter expects (resource $prepare, long $status).

Return Value

*long *:

Example
uv_prepare_start($prepare, function($rsc, $status){
    echo "Hello";
    uv_unref($rsc);
});

uv_run();

void uvpreparestop(resource $handle)

Description

stop prepare callback

Parameters

resource $prepare: uv resource handle (prepare)

Return Value

long:

resource uvcheckinit([resource $loop])

Description

setup check resource

Parameters

resource $loop: uv loop handle

Return Value

resource uv_check:

Example

void uvcheckstart(resource $handle, callable $callback)

Description

stats check loop callback. (after loop callback)

Parameters

resource $handle: uv resource handle (check)

callable $callback: this callback parameter expects (resource $check, long $status).

Return Value

*long *:

Example
$idle = uv_idle_init();

$i = 0; uv_idle_start($idle, function($stat) use (&$i, $idle, $loop){ echo "count: {$i}" . PHP_EOL; $i++;

if ($i > 3) {
    uv_idle_stop($idle);
}
sleep(1);

});

uv_check_start($check, function($check, $status){ echo "Hello"; uv_check_stop($check); });

uv_run();

void uvcheckstop(resource $handle)

Description

stop check callback

Parameters

resource $check: uv resource handle (check)

Return Value

*void *:

resource uvasyncinit(resource $loop, callable $callback)

Description

setup async callback

Parameters

resource $loop: uv loop resource

callback $callback:

Return Value

*resource *: uv async resource

Example

void uvasyncsend(resource $handle)

Description

send async callback immidiately

Parameters

resource $handle: uv async handle

Return Value

void:

Example

void uvqueuework(resource $loop, callable $callback, callable $after_callback)

Description

execute callbacks in another thread (requires Thread Safe enabled PHP)

resource uvfsopen(resource $loop, string $path, long $flag, long $mode, callable $callback)

Description

open specified file

Parameters

resource $loop: uv_loop resource.

string $path: file path

long $flag: file flag. this should be UV::O_RDONLY and some constants flag.

long $mode: mode flag. this should be UV::S_IRWXU and some mode flag.

callable $calback: this callback parameter expects (resource $stream)

Return Value

void:

Example
uv_fs_write(uv_default_loop(),$r,"hello",0, function($a) use ($r){
    uv_fs_fdatasync(uv_default_loop(),$r,function(){
        echo "fsync finished";
    });
});

});

uv_run();

void uvfsread(resource $loop, zval $fd, long $offset, long $length, callable $callback)

Description

async read.

Parameters

resource $loop: uv loop handle

zval $fd: this expects long $fd, resource $phpstream or resource $phpsocket.

long $offset: the offset position in the file at which reading should commence.

long $length: the length in bytes that should be read starting at position $offset.

resource $callback: this callback parameter expects (zval $fd, long $nread, string $buffer).

Return Value

*void *:

void uvfsclose(resource $loop, zval $fd, callable $callback)

Description

close specified file descriptor.

Parameters

resource $loop: uv_loop resource.

zval $fd: file descriptor. this expects long $fd, resource $phpstream or resource $phpsocket.

callable $calback: this callback parameter expects (resource $stream)

Return Value

void:

Example
todo

  • handling PHP's stream and socket correctly.

void uvfswrite(resource $loop, zval $fd, string $buffer, long $offset, callable $callback)

Description

write buffer to specified file descriptor.

Parameters

resource $loop: uv_loop resource.

zval $fd: file descriptor. this expects long $fd, resource $phpstream or resource $phpsocket.

string $buffer: buffer.

callable $calback: this callback parameter expects (resource $stream, long $result)

Return Value

void:

Example

void uvfsfsync(resource $loop, zval $fd, callable $callback)

Description

async fsync

Parameters

resource $handle: uv loop handle

zval $fd:

callable $callback:

Return Value

void:

Example

void uvfsfdatasync(resource $loop, zval $fd, callable $callback)

Description

async fdatasync

Parameters

resource $handle: uv loop handle

zval $fd:

callable $callback:

Return Value

void:

Example

void uvfsftruncate(resource $loop, zval $fd, long $offset, callable $callback)

Description

async ftruncate

Parameters

resource $handle: uv loop handle

zval $fd:

long $offset:

callable $callback:

Return Value

void:

Example

void uvfsmkdir(resource $loop, string $path, long $mode, callable $callback)

Description

async mkdir

Parameters

resource $handle: uv loop handle

string $path:

long $mode:

callable $callback:

Return Value

void:

Example

void uvfsrmdir(resource $loop, string $path, callable $callback)

Description

async rmdir

Parameters

resource $handle: uv loop handle

string $path:

callable $callback:

Return Value

void:

Example

void uvfsunlink(resource $loop, string $path, callable $callback)

Description

async unlink

Parameters

resource $handle: uv loop handle

string $path:

callable $callback:

Return Value

void:

Example

void uvfsrename(resource $loop, string $from, string $to, callable $callback)

Description

async rename

Parameters

resource $handle: uv loop handle

string $from:

string $to:

callable $callback:

Return Value

void:

Example

void uvfsutime(resource $loop, string $path, long $utime, long $atime, callable $callback)

Description

async utime

Parameters

resource $handle: uv loop handle

string $path:

long $utime:

long $atime:

callable $callback:

Return Value

void:

Example

void uvfsfutime(resource $loop, zval $fd, long $utime, long $atime callable $callback)

Description

async futime

Parameters

resource $handle: uv loop handle

zval $fd:

long $utime:

long $atime:

callable $callback:

Return Value

void:

Example

void uvfschmod(resource $loop, string $path, long $mode, callable $callback)

Description

async chmod

Parameters

resource $handle: uv loop handle

string $path:

long $mode:

callable $callback:

Return Value

void:

Example

void uvfsfchmod(resource $loop, zval $fd, long $mode, callable $callback)

Description

async fchmod

Parameters

resource $handle: uv loop handle

zval $fd:

long $mode:

callable $callback:

Return Value

void:

Example

void uvfschown(resource $loop, string $path, long $uid, long $gid, callable $callback)

Description

async chown

Parameters

resource $handle: uv loop handle

string $paht:

long $uid:

long $gid:

callable $callback:

Return Value

void:

Example

void uvfsfchown(resource $loop, zval $fd, long $uid, $long $gid, callable $callback)

Description

async fchown

Parameters

resource $handle: uv loop handle

zval $fd:

long $uid:

long $gid:

callable $callback:

Return Value

void:

Example

void uvfslink(resource $loop, string $from, string $to, callable $callback)

Description

async link

Parameters

resource $handle: uv loop handle

string $from:

string $to:

callable $callback:

Return Value

void:

Example

void uvfssymlink(resource $loop, string $from, string $to, long $flags, callable $callback)

Description

async symlink

Parameters

resource $handle: uv loop handle

string $from:

string $to:

long $flags:

callable $callback:

Return Value

void:

Example

void uvfsreadlink(resource $loop, string $path, callable $callback)

Description

async readlink

Parameters

resource $handle: uv loop handle

string $path:

callable $callback:

Return Value

void:

Example

void uvfsstat(resource $loop, string $path, callable $callback)

Description

async stat

Parameters

resource $handle: uv loop handle

string $path:

callable $callback: this callback parameter expects (resource $stream, array $stat)

Return Value

void:

Example

void uvfslstat(resource $loop, string $path, callable $callback)

Description

async lstat

Parameters

resource $handle: uv loop handle

string $path:

callable $callback:

Return Value

void:

Example

void uvfsfstat(resource $loop, zval $fd, callable $callback)

Description

async fstat

Parameters

resource $handle: uv loop handle

zval $fd:

callable $callback:

Return Value

void:

Example

uvfsreaddir(resource $loop, string $path, long $flags, callable $callback)

Description

async readdir

Parameters

resource $handle: uv loop handle

string $path:

long $flags:

callable $callback:

Return Value

void:

Example

void uvfssendfile(resource $loop, zval $infd, zval $outfd, long $offset, long $length, callable $callback)

Description

async sendfile

Parameters

resource $handle: uv loop handle

zval $in_fd:

zval $out_fd:

long $offset:

long $length:

callable $callback:

Return Value

void:

Example

resource uvfsevent_init(resource $loop, string $path, callable $callback, long $flags = 0)

Description

initialize fs event.

Parameters

resource $handle: uv loop handle

string $path:

callable $callback:

Return Value

void:

Example

resource uvttyinit(resource $loop, zval $fd, long $readable)

Description

initialize tty resource. you have to open tty your hand.

Parameters

resource $handle: uv loop handle

zval $fd:

long $readable:

Return Value

resource $uv_tty:

Example

long uvttyget_winsize(resource $tty, long &$width, long &$height)

long uvttyset_mode(resource $tty, long $mode)

void uvttyreset_mode(void)

string uvtcpgetsockname(resource $uv_sockaddr)

string uvtcpgetpeername(resource $uv_sockaddr)

string uvudpgetsockname(resource $uv_sockaddr)

long uvresidentset_memory(void)

string uvip4name(resource uv_sockaddr $address)

string uvip6name(resource uv_sockaddr $address)

uv uvpollinit([resource $uv_loop], zval fd)

Description

initialize poll

Parameters

resource $uv_loop: uv_loop resource.

mixed $fd: this expects long fd, PHP's stream or PHP's socket resource.

Return Value

resource uv: uv resource which initialized poll.

Example
$poll = uv_poll_init(uv_default_loop(), $fd);

Note

  • some platform doesn't support file descriptor on these method.

uv uvpollstart(resource $handle, $events, $callback)

Description

start polling

Parameters

resource $poll: uv poll resource.

long $events: UV::READBLE and UV::WRITABLE flags.

callable $callback: this callback parameter expects (resource $poll, long $status, long $events, mixed $connection). the connection parameter passes uvpollinit'd fd.

Return Value

void:

Example
$poll = uv_poll_init(uv_default_loop(), $fd);
uv_poll_start($poll, UV::WRITABLE, function($poll, $stat, $ev, $conn){
        fwrite($conn, "Hello");
        fclose($conn);
        uv_poll_stop($poll);
});

uv_run();

Note

  • if you want to use a socket. please use uvpollinit_socket instead of this. Windows can't handle socket with this function.

void uvpollstop(resource $poll)

uv uvfspollinit([resource $uvloop])

uv uvfspoll_start(resource $handle, $callback, string $path, long $interval)

void uvfspoll_stop(resource $poll)

void uvstop([resource $uvloop])

Description
Parameters

resource $uv_loop: uv loop handle

Return Value

void:

Example

resource uvsignalinit([resource $uv_loop])

Description
Parameters

resource $uv_loop: uv loop handle

Return Value

resource:

Example

void uvsignalstart(resource $sighandle, callable $sigcallback, int $sig_num)

Description
Parameters

resource $sig_handle:

callable $callable: signal callback

int $sig_num: signal

Return Value

void:

Example

int uvsignalstop(resource $sig_handle)

Description
Parameters

resource $sig_handle:

Return Value

int $sig_num:

Example

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.