2017 © Pedro Peláez
 

library smb

php wrapper for smbclient and libsmbclient-php forked by icewind1991/SMB

image

sgrabaum/smb

php wrapper for smbclient and libsmbclient-php forked by icewind1991/SMB

  • Wednesday, November 11, 2015
  • by steffen-99
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4,883 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 25 Forks
  • 0 Open issues
  • 9 Versions
  • 20 % Grown

The README.md

SMB

Project is forked by icewind1991/SMB to give localisations of connections. In version 1.0.4 only US available., (*1)

PHP wrapper for smbclient and libsmbclient-php, (*2)

  • Reuses a single smbclient instance for multiple requests
  • Doesn't leak the password to the process list
  • Simple 1-on-1 mapping of SMB commands
  • A stream-based api to remove the need for temporary files
  • Support for using libsmbclient directly trough libsmbclient-php

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 $info) {
    echo $name->getName() . "\n";
    echo "\tsize :" . $info->getSize() . "\n";
}

Using read streams

<?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);

Using write streams

<?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);

Using Localization

<?php
use Icewind\SMB\Server;

require('vendor/autoload.php');

$server = new Server('localhost', 'test', 'test');
$oServer->setConnectionEnv( [ 'LC_ALL' => 'de_DE.UTF-8', 'LANG' => 'de_DE.UTF-8' ] ); // de_DE.UTF-8 = german language and files with german characters
$share = $server->getShare('test', '?? M d H:i:s Y T'); //  Format "?? M d H:i:s Y T" is german language date time result of smbclient, need for parser to get timestamp

$fh = $share->write('test.txt');
fwrite($fh, 'bar');
fclose($fh);

Using libsmbclient-php

Install libsmbclient-php, (*3)

<?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');

The Versions

11/11 2015

dev-master

9999999-dev

php wrapper for smbclient and libsmbclient-php forked by icewind1991/SMB

  Sources   Download

MIT

The Requires

 

The Development Requires

by Steffen Grabaum

11/11 2015

1.0.5.1

1.0.5.1

php wrapper for smbclient and libsmbclient-php forked by icewind1991/SMB

  Sources   Download

MIT

The Requires

 

The Development Requires

by Steffen Grabaum

10/11 2015

v1.0.5

1.0.5.0

php wrapper for smbclient and libsmbclient-php forked by icewind1991/SMB

  Sources   Download

MIT

The Requires

 

The Development Requires

by Steffen Grabaum

17/08 2015

v1.0.4

1.0.4.0

php wrapper for smbclient and libsmbclient-php

  Sources   Download

MIT

The Requires

 

The Development Requires

13/08 2015

v1.0.3a

1.0.3.0-alpha

php wrapper for smbclient and libsmbclient-php

  Sources   Download

MIT

The Requires

 

The Development Requires

13/08 2015

v1.0.3

1.0.3.0

php wrapper for smbclient and libsmbclient-php

  Sources   Download

MIT

The Requires

 

The Development Requires

24/06 2015

v1.0.2

1.0.2.0

php wrapper for smbclient and libsmbclient-php

  Sources   Download

MIT

The Requires

 

The Development Requires

20/04 2015

v1.0.1

1.0.1.0

php wrapper for smbclient and libsmbclient-php

  Sources   Download

MIT

The Requires

 

The Development Requires

10/04 2015

v1.0.0

1.0.0.0

php wrapper for smbclient and libsmbclient-php

  Sources   Download

MIT

The Requires

 

The Development Requires