osw3 / php-cloud-manager
Provides cloud connection and file manipulation tools.
Requires
README
Provides cloud connection and file manipulation tools.
How to install
composer require osw3/php-cloud-manager
Supported services
How to use
Create new connection
Prepare the DSN
$dsn = "{$driver}://{$user}:{$pass}@{$host}";
Client instance
use OSW3\CloudManager\Client; $client = new Client($dsn);
Don't auto connect
$client = new Client($dsn, false); $client->connect();
DSN Infos
-
dsn(): DsnService
Bridge to DsnService.
$client->dsn()->getDriver(); // ftp
-
getDriver(): ?string
$client->dsn()->getDriver(); // ftp
-
getHost(): ?string
$client->dsn()->getHost(); // site.com
-
getUser(): ?string
$client->dsn()->getUser(); // user
-
getPass(): ?string
$client->dsn()->getPass(); // pass
-
getAuth(): ?int
Get the Auth mode
$client->dsn()->getAuth();
-
getToken(): ?int
$client->dsn()->getToken();
-
getPort(): ?int
$client->dsn()->getPort(); // 21
-
get(): ?string
Get the DSN string
$client->dsn()->get(); // ftp://user:pass@site.com";
Driver Statement
-
connect(): bool
Proceed to driver connection and return the connection state
$client->connect();
-
disconnect(): bool
Proceed to disconnection and return the connection status
$client->disconnect();
-
isConnected(): bool
return
true
when the driver is connected$client->isConnected();
Temp directory
-
setTempDirectory(string $directory): static
Set the local server Temp directory for file manipulation.
$client->setTempDirectory("my/temp/dir");
-
getTempDirectory(): string
Get the local server Temp directory for file manipulation.
$client->getTempDirectory();
Navigation
-
location(): string
Return the current location (like PWD)
$client->location();
-
navigateTo(string $folder): bool
Set the pointer to a specific folder.
$client->navigateTo("/www");
-
parent(): bool
Set the pointer to a parent folder.
$client->parent();
-
root(): bool
Set the pointer to the root of the driver.
$client->root();
Entry infos
-
infos(?string $path=null, ?string $part=null): array|string
Retrieve the entry infos. Return an array if $part is null.
$client->infos("/www/my-dir"); // [...] $client->infos("/www/my-dir", "type"); // folder
-
isFolder(string $path): bool
True if $path is a folder type.
$client->isFolder("/www/my-dir");
-
isDirectory(string $path): bool
An alias of isFolder
$client->isDirectory("/www/my-dir");
-
isFile(string $path): bool
True if $path is a file type.
$client->isFile("/www/my-dir");
-
isLink(string $path): bool
True if $path is a link type.
$client->isLink("/www/my-dir");
-
isBlock(string $path): bool
True if $path is a block type
$client->isBlock("/www/my-dir");
-
isCharacter(string $path): bool
True if $path is a character type.
$client->isCharacter("/www/my-dir");
-
isSocket(string $path): bool
True if $path is a socket type.
$client->isSocket("/www/my-dir");
-
isPipe(string $path): bool
True if $path is a pipe type.
$client->isPipe("/www/my-dir");
Permissions
-
permissions(string $path, ?int $code=null): string|bool
Permissions getter and setter. Set permission to path if
$code
is notnull
. Get permission code if$code
isnull
$client->permissions("/www/my-dir", 0777); // true $client->permissions("/www/my-dir"); // 0777
-
setPermission(string $path, int $code): bool
Set permissions code to a $path
$client->setPermission("/www/my-dir", 0777);
-
getPermission(string $path): string
Read permissions code from a $path
$client->getPermission("/www/my-dir"); // 0777
Folder API
-
browse(?string $directory=null): array
Return the content of a directory, like the Unix PWD command. Return the current pointer location content if the
$directory
parameter isnull
.$client->browse("/www/my-dir"); // [...]
-
createFolder(string $directory, int $permissions=0700, bool $navigateTo = true): bool
Create a directory and set the pointer into the new location id
$navigateTo
istrue
.$client->createFolder("/www/my-dir/my-sub-dir");
-
deleteFolder(?string $directory, bool $recursive=true): bool
Delete a directory and its contains.
$client->deleteFolder("/www/my-dir/my-sub-dir");
-
duplicateFolder(string $source, string $destination): bool
Duplicate a directory on the Client
$client->duplicateFolder("/www/my-dir", "/www/my-other-dirt");
-
copyFolder(string $source, string $destination): bool
Alias for
duplicateFolder
. -
moveFolder(string $source, string $destination, bool $override=false): bool
Move a folder (cut + paste)
$client->moveFolder("C://my-dir", "/www/my-dir");
-
uploadFolder(string $source, string $destination, bool $override=false): bool
Send a directory from your server to the remote Client
$client->uploadFolder("C://my-dir", "/www/my-dir");
-
downloadFolder(string $source, string $destination, bool $override=false): bool
Get a directory from a Client to your server
$client->downloadFolder("/www/my-dir", "C://my-dir");
Files API
-
createFile(string $filename, string $content="", bool $binary=false): bool
Create a file from Stream to the Client.
$client->createFile("/www/my-dir/my-file.txt", "Hi!\This is my file.");
-
deleteFile(?string $filename): bool
Delete a file from a Client.
$client->deleteFile("/www/my-dir/my-file.txt");
-
duplicateFile(string $source, string $destination): bool
Duplicate a file on the Client
$client->duplicateFile("/www/my-dir/my-file.txt", "/www/my-other-dir/my-file.txt");
-
copyFile(string $source, string $destination): bool
Alias for
duplicateFile
. -
moveFile(string $source, string $destination, bool $override=false): bool
Move a file
$client->moveFile("C://my-dir/my-file.txt", "/www/my-dir/my-file.txt");
-
uploadFile(string $source, string $destination, bool $override=false): bool
Send a file from your server to the remote Client
$client->uploadFile("C://my-dir/my-file.txt", "/www/my-dir/my-file.txt");
-
downloadFile(string $source, string $destination, bool $override=false): bool
Get a file from a Client to your server
$client->downloadFile("/www/my-dir/my-file.txt", "C://my-dir/my-file.txt");
Folder & Files API (Hybrid aliases of previous API)
-
delete(?string $path, bool $recursive=true): bool
;Delete a directory or a file
$client->delete("/www/my-dir/my-file.txt"); $client->delete("/www/my-dir");
-
duplicate(string $source, string $destination): bool
;Duplicate a directory or a file
$client->duplicate("/www/my-dir/my-file.txt", "/www/my-sub-dir/my-file.txt"); $client->duplicate("/www/my-dir", "/www/my-sub-dir");
-
copy(string $source, string $destination): bool
;Alias of
duplicate
-
move(string $source, string $destination): bool
;Duplicate a directory or a file and delete the
$source
.$client->move("/www/my-dir/my-file.txt", "/www/my-sub-dir/my-file.txt"); $client->move("/www/my-dir", "/www/my-sub-dir");
-
rename(string $source, string $destination): bool
;Alias of
move
-
upload(string $source, string $destination, bool $override=false): bool
;Send a directory or a file from your server to the Client
$client->upload("C://my-dir", "/www/my-dir"); $client->upload("C://my-dir/my-file.txt", "/www/my-dir/my-file.txt");
-
download(string $source, string $destination, bool $override=false): bool
;Get a directory or a file from the Client to your server
$client->download("/www/my-dir", "C://my-dir"); $client->download("/www/my-dir/my-file.txt", "C://my-dir/my-file.txt");