mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
add info about basic connection testing using the example script
This commit is contained in:
parent
0cbfd0872d
commit
2280570d28
2 changed files with 21 additions and 3 deletions
12
README.md
12
README.md
|
|
@ -150,3 +150,15 @@ $share->notify('')->listen(function (\Icewind\SMB\Change $change) {
|
||||||
echo $change->getCode() . ': ' . $change->getPath() . "\n";
|
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.
|
||||||
|
|
|
||||||
12
example.php
12
example.php
|
|
@ -1,16 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Icewind\SMB\NativeServer;
|
use Icewind\SMB\NativeServer;
|
||||||
use Icewind\SMB\Server;
|
use Icewind\SMB\Server;
|
||||||
|
|
||||||
require('vendor/autoload.php');
|
require('vendor/autoload.php');
|
||||||
|
|
||||||
|
$host = 'localhost';
|
||||||
|
$user = 'test';
|
||||||
|
$password = 'test';
|
||||||
|
$share = 'test';
|
||||||
|
|
||||||
if (Server::NativeAvailable()) {
|
if (Server::NativeAvailable()) {
|
||||||
$server = new NativeServer('localhost', 'test', 'test');
|
$server = new NativeServer($host, $user, $password);
|
||||||
} else {
|
} else {
|
||||||
$server = new Server('localhost', 'test', 'test');
|
$server = new Server($host, $user, $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
$share = $server->getShare('test');
|
$share = $server->getShare($share);
|
||||||
|
|
||||||
$files = $share->dir('/');
|
$files = $share->dir('/');
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue