mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
PHP wrapper for smbclient
- PHP 98.3%
- Shell 1.3%
- Nix 0.3%
- Makefile 0.1%
| src | ||
| tests | ||
| .gitignore | ||
| composer.json | ||
| COPYING-AGPL | ||
| COPYING-README | ||
| README.md | ||
SMB
PHP wrapper for smbclient
- Reuses a single
smbclientinstance for multiple requests - Doesn't leak the password to the process list
- Simple 1-on-1 mapping of SMB commands
Examples
Upload a file
<?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');
Download a file
<?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);
List shares on the remote server
<?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";
}
List the content of a folder
<?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 $name => $info) {
echo $name . "\n";
echo "\tsize :" . $info['size'] . "\n";
}