Skip to content

Commit 2280570

Browse files
committed
add info about basic connection testing using the example script
1 parent 0cbfd08 commit 2280570

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

README.md

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

example.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
<?php
2+
23
use Icewind\SMB\NativeServer;
34
use Icewind\SMB\Server;
45

56
require('vendor/autoload.php');
67

8+
$host = 'localhost';
9+
$user = 'test';
10+
$password = 'test';
11+
$share = 'test';
12+
713
if (Server::NativeAvailable()) {
8-
$server = new NativeServer('localhost', 'test', 'test');
14+
$server = new NativeServer($host, $user, $password);
915
} else {
10-
$server = new Server('localhost', 'test', 'test');
16+
$server = new Server($host, $user, $password);
1117
}
1218

13-
$share = $server->getShare('test');
19+
$share = $server->getShare($share);
1420

1521
$files = $share->dir('/');
1622
foreach ($files as $file) {

0 commit comments

Comments
 (0)