Robin Appelman 0aa211eefb Add missing smb files | преди 7 години | |
---|---|---|
.. | ||
src | 0aa211eefb Add missing smb files | преди 7 години |
.gitignore | 3159af1983 Wait with getting the timezone from the smb server until we need it | преди 9 години |
LICENSE.txt | d2255a1d30 New SMB storage backend | преди 9 години |
README.md | 8429687788 Update icewind/smb to 2.0.0 | преди 7 години |
composer.json | 8429687788 Update icewind/smb to 2.0.0 | преди 7 години |
PHP wrapper for smbclient
and libsmbclient-php
smbclient
instance for multiple requestslibsmbclient-php
<?php
use Icewind\SMB\Server;
require('vendor/autoload.php');
$fileToUpload = __FILE__;
$server = new Server('localhost', 'test', 'test');
$share = $server->getShare('test');
$share->put($fileToUpload, 'example.txt');
<?php
use Icewind\SMB\Server;
require('vendor/autoload.php');
$target = __DIR__ . '/target.txt';
$server = new Server('localhost', 'test', 'test');
$share = $server->getShare('test');
$share->get('example.txt', $target);
<?php
use Icewind\SMB\Server;
require('vendor/autoload.php');
$server = new Server('localhost', 'test', 'test');
$shares = $server->listShares();
foreach ($shares as $share) {
echo $share->getName() . "\n";
}
<?php
use Icewind\SMB\Server;
require('vendor/autoload.php');
$server = new Server('localhost', 'test', 'test');
$share = $server->getShare('test');
$content = $share->dir('test');
foreach ($content as $info) {
echo $info->getName() . "\n";
echo "\tsize :" . $info->getSize() . "\n";
}
<?php
use Icewind\SMB\Server;
require('vendor/autoload.php');
$server = new Server('localhost', 'test', 'test');
$share = $server->getShare('test');
$fh = $share->read('test.txt');
echo fread($fh, 4086);
fclose($fh);
<?php
use Icewind\SMB\Server;
require('vendor/autoload.php');
$server = new Server('localhost', 'test', 'test');
$share = $server->getShare('test');
$fh = $share->write('test.txt');
fwrite($fh, 'bar');
fclose($fh);
Install libsmbclient-php
<?php
use Icewind\SMB\Server;
use Icewind\SMB\NativeServer;
require('vendor/autoload.php');
$fileToUpload = __FILE__;
if (Server::NativeAvailable()) {
$server = new NativeServer('localhost', 'test', 'test');
} else {
echo 'libsmbclient-php not available, falling back to wrapping smbclient';
$server = new Server('localhost', 'test', 'test');
}
$share = $server->getShare('test');
$share->put($fileToUpload, 'example.txt');
<?php
use Icewind\SMB\Server;
require('vendor/autoload.php');
$server = new Server('localhost', 'test', 'test');
$share = $server->getShare('test');
$share->notify('')->listen(function (\Icewind\SMB\Change $change) {
echo $change->getCode() . ': ' . $change->getPath() . "\n";
});