osw3 / php-cloud-manager
Provides cloud connection and file manipulation tools.
Requires
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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(): DsnServiceBridge 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(): ?intGet the Auth mode
$client->dsn()->getAuth();
-
getToken(): ?int$client->dsn()->getToken();
-
getPort(): ?int$client->dsn()->getPort(); // 21
-
get(): ?stringGet the DSN string
$client->dsn()->get(); // ftp://user:pass@site.com";
Driver Statement
-
connect(): boolProceed to driver connection and return the connection state
$client->connect();
-
disconnect(): boolProceed to disconnection and return the connection status
$client->disconnect();
-
isConnected(): boolreturn
truewhen the driver is connected$client->isConnected();
Temp directory
-
setTempDirectory(string $directory): staticSet the local server Temp directory for file manipulation.
$client->setTempDirectory("my/temp/dir");
-
getTempDirectory(): stringGet the local server Temp directory for file manipulation.
$client->getTempDirectory();
Navigation
-
location(): stringReturn the current location (like PWD)
$client->location();
-
navigateTo(string $folder): boolSet the pointer to a specific folder.
$client->navigateTo("/www");
-
parent(): boolSet the pointer to a parent folder.
$client->parent();
-
root(): boolSet the pointer to the root of the driver.
$client->root();
Entry infos
-
infos(?string $path=null, ?string $part=null): array|stringRetrieve 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): boolTrue if $path is a folder type.
$client->isFolder("/www/my-dir");
-
isDirectory(string $path): boolAn alias of isFolder
$client->isDirectory("/www/my-dir");
-
isFile(string $path): boolTrue if $path is a file type.
$client->isFile("/www/my-dir");
-
isLink(string $path): boolTrue if $path is a link type.
$client->isLink("/www/my-dir");
-
isBlock(string $path): boolTrue if $path is a block type
$client->isBlock("/www/my-dir");
-
isCharacter(string $path): boolTrue if $path is a character type.
$client->isCharacter("/www/my-dir");
-
isSocket(string $path): boolTrue if $path is a socket type.
$client->isSocket("/www/my-dir");
-
isPipe(string $path): boolTrue if $path is a pipe type.
$client->isPipe("/www/my-dir");
Permissions
-
permissions(string $path, ?int $code=null): string|boolPermissions getter and setter. Set permission to path if
$codeis notnull. Get permission code if$codeisnull$client->permissions("/www/my-dir", 0777); // true $client->permissions("/www/my-dir"); // 0777
-
setPermission(string $path, int $code): boolSet permissions code to a $path
$client->setPermission("/www/my-dir", 0777);
-
getPermission(string $path): stringRead permissions code from a $path
$client->getPermission("/www/my-dir"); // 0777
Folder API
-
browse(?string $directory=null): arrayReturn the content of a directory, like the Unix PWD command. Return the current pointer location content if the
$directoryparameter isnull.$client->browse("/www/my-dir"); // [...]
-
createFolder(string $directory, int $permissions=0700, bool $navigateTo = true): boolCreate a directory and set the pointer into the new location id
$navigateToistrue.$client->createFolder("/www/my-dir/my-sub-dir");
-
deleteFolder(?string $directory, bool $recursive=true): boolDelete a directory and its contains.
$client->deleteFolder("/www/my-dir/my-sub-dir");
-
duplicateFolder(string $source, string $destination): boolDuplicate a directory on the Client
$client->duplicateFolder("/www/my-dir", "/www/my-other-dirt");
-
copyFolder(string $source, string $destination): boolAlias for
duplicateFolder. -
moveFolder(string $source, string $destination, bool $override=false): boolMove a folder (cut + paste)
$client->moveFolder("C://my-dir", "/www/my-dir");
-
uploadFolder(string $source, string $destination, bool $override=false): boolSend 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): boolGet 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): boolCreate a file from Stream to the Client.
$client->createFile("/www/my-dir/my-file.txt", "Hi!\This is my file.");
-
deleteFile(?string $filename): boolDelete a file from a Client.
$client->deleteFile("/www/my-dir/my-file.txt");
-
duplicateFile(string $source, string $destination): boolDuplicate 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): boolAlias for
duplicateFile. -
moveFile(string $source, string $destination, bool $override=false): boolMove a file
$client->moveFile("C://my-dir/my-file.txt", "/www/my-dir/my-file.txt");
-
uploadFile(string $source, string $destination, bool $override=false): boolSend 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): boolGet 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");