\pm_ServerFileManager

Manager of files on server level.

Summary

Methods
Properties
Constants
__construct()
getFilePath()
fileExists()
filePutContents()
fileGetContents()
mkdir()
touch()
chmod()
copyFile()
moveFile()
removeFile()
removeDirectory()
fileSize()
joinPath()
scanDir()
find()
isSubpath()
getRelativeFilePath()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A

Methods

__construct()

__construct() 

Creates new instance of manager

getFilePath()

getFilePath(string  $path) : string

Returns full path on filesystem by relative path inside webspace

Parameters

string $path

Returns

string

fileExists()

fileExists(string  $filename) : boolean

Checks whether a file or directory exists.

Parameters

string $filename

Returns

boolean

filePutContents()

filePutContents(string  $filename, string  $data) 

Writes a string data to a file

Parameters

string $filename
string $data

fileGetContents()

fileGetContents(string  $filename) : string

Reads entire file into a string

Parameters

string $filename

Returns

string

mkdir()

mkdir(string  $dirname, string  $perms = '0755', boolean  $recursively = false) 

Creates a directory by path ($perms and $recursively are ignored on Windows)

Parameters

string $dirname
string $perms
boolean $recursively

touch()

touch(  $filename) 

Updates the access date and / or modification date of a file or directory.

Parameters

$filename

chmod()

chmod(string  $filename, string  $mode) 

Changes the access permissions to file system objects (files and directories) totally are ignored on Windows

Parameters

string $filename
string $mode

copyFile()

copyFile(string  $source, string  $destination) 

Copies file system objects (files and directories) from source to destination

Parameters

string $source
string $destination

moveFile()

moveFile(string  $source, string  $destination) 

Moves file system objects (files and directories) from source to destination

Parameters

string $source
string $destination

removeFile()

removeFile(string  $filename) 

Removes file by name

Parameters

string $filename

removeDirectory()

removeDirectory(string  $dirname) 

Removes directory by name

Parameters

string $dirname

fileSize()

fileSize(string  $filename) : string

Returns file size in bytes

Parameters

string $filename

Returns

string

joinPath()

joinPath(array<mixed,string>  $pathParts) : string

Returns joined path parts

Parameters

array<mixed,string> $pathParts

Parts for joining to path

Returns

string

scanDir()

scanDir(string  $path, boolean  $skipDots = false, boolean  $showSystemFiles = true) : array<mixed,string>

Returns list of files and directories inside the specified path

Parameters

string $path
boolean $skipDots
boolean $showSystemFiles

Returns

array<mixed,string> —

List of file names

find()

find(array<mixed,string>  $patterns, boolean  $recursively = true, string  $path = '/') : array<mixed,string>

Returns list of paths inside the specified sources that match the patterns

Parameters

array<mixed,string> $patterns

List of patterns, which will be searched

boolean $recursively

[optional] Whether a recursive search should be done. Default is true

string $path

[optional] Path where search will be performed. Default is /

Returns

array<mixed,string> —

List of paths

isSubpath()

isSubpath(string  $path) : boolean

Checks if path is inside webspace

Parameters

string $path

Returns

boolean

getRelativeFilePath()

getRelativeFilePath(string  $path) : string

Returns relative path inside webspace by full path

Parameters

string $path

Returns

string