phpsftpnonblockingssh2-sftp

Non blocking up/downloads using ssh2_sftp


How can I use non-blocking up/downloads with ssh2_sftp_ (like with ftp_nb_put/ftp_nb_get)?


Solution

  • The PHP SSH2 functions do not support non-blocking operation. Neither phpseclib does.


    But you can move your download code to a separate thread using the Thread PECL class.

    For an example see:
    How can one use multi threading in PHP applications


    Or you can upload the file in chunks.
    See https://phpseclib.com/docs/sftp#positional-control