add info about basic connection testing using the example script

This commit is contained in:
Robin Appelman 2018-03-09 15:01:40 +01:00
commit 2280570d28
2 changed files with 21 additions and 3 deletions

View file

@ -150,3 +150,15 @@ $share->notify('')->listen(function (\Icewind\SMB\Change $change) {
echo $change->getCode() . ': ' . $change->getPath() . "\n";
});
```
## Testing SMB
Use the following steps to check if the library can connect to your SMB share.
1. Clone this repository or download the source as [zip](https://github.com/icewind1991/SMB/archive/master.zip)
2. Make sure [composer](https://getcomposer.org/) is installed
3. Run `composer install` in the root of the repository
4. Edit `example.php` with the relevant settings for your share.
5. Run `php example.php`
If everything works correctly then the contents of the share should be outputted.

View file

@ -1,16 +1,22 @@
<?php
use Icewind\SMB\NativeServer;
use Icewind\SMB\Server;
require('vendor/autoload.php');
$host = 'localhost';
$user = 'test';
$password = 'test';
$share = 'test';
if (Server::NativeAvailable()) {
$server = new NativeServer('localhost', 'test', 'test');
$server = new NativeServer($host, $user, $password);
} else {
$server = new Server('localhost', 'test', 'test');
$server = new Server($host, $user, $password);
}
$share = $server->getShare('test');
$share = $server->getShare($share);
$files = $share->dir('/');
foreach ($files as $file) {