SMB === [![Code Coverage](https://scrutinizer-ci.com/g/icewind1991/SMB/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/icewind1991/SMB/?branch=master) [![Build Status](https://travis-ci.org/icewind1991/SMB.svg?branch=master)](https://travis-ci.org/icewind1991/SMB) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/icewind1991/SMB/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/icewind1991/SMB/?branch=master) PHP wrapper for `smbclient` and [`libsmbclient-php`](https://github.com/eduardok/libsmbclient-php) - Reuses a single `smbclient` instance for multiple requests - Doesn't leak the password to the process list - Simple 1-on-1 mapping of SMB commands - A stream-based api to remove the need for temporary files - Support for using libsmbclient directly trough [`libsmbclient-php`](https://github.com/eduardok/libsmbclient-php) Examples ---- ### Upload a file ### ```php getShare('test'); $share->put($fileToUpload, 'example.txt'); ``` ### Download a file ### ```php getShare('test'); $share->get('example.txt', $target); ``` ### List shares on the remote server ### ```php listShares(); foreach ($shares as $share) { echo $share->getName() . "\n"; } ``` ### List the content of a folder ### ```php getShare('test'); $content = $share->dir('test'); foreach ($content as $info) { echo $info->getName() . "\n"; echo "\tsize :" . $info->getSize() . "\n"; } ``` ### Using read streams ```php getShare('test'); $fh = $share->read('test.txt'); echo fread($fh, 4086); fclose($fh); ``` ### Using write streams ```php getShare('test'); $fh = $share->write('test.txt'); fwrite($fh, 'bar'); fclose($fh); ``` ### Using libsmbclient-php ### Install [libsmbclient-php](https://github.com/eduardok/libsmbclient-php) ```php getShare('test'); $share->put($fileToUpload, 'example.txt'); ``` ### Using notify ```php getShare('test'); $share->notify('')->listen(function (\Icewind\SMB\Change $change) { echo $change->getCode() . ': ' . $change->getPath() . "\n"; }); ```