A powerful PHP library for parsing and working with FileZilla sitemanager.xml
files. It allows you to extract server
details, manage configurations, and integrate FileZilla data into your PHP applications.
- π Parse FileZilla
sitemanager.xml
files: Extract and work with server folders as well as individual server details. - π Stop using credentials in your code: If FileZilla already provides this unencrypted, and you're already using it, why not just read it from there?
- β¨ Supports all FileZilla server attributes: Including host, port, protocol, and more.
- π§ Flexible API: Query specific server details or all servers in a folder.
- π Enum-Based Design: Strongly typed enums for protocols, logon types, and more.
- βοΈ Works out of the box: The library defaults to the
sitemanager.xml
of your system. No need to specify a path. - π PHP 8.0+ Compatible: Built with modern PHP practices and strict typing.
Install the package via Composer:
composer require jalsoedesign/filezilla
Load the default sitemanager.xml from your system (using fromSystem()
) and iterate through all servers and print their
name.
use jalsoedesign\filezilla\SiteManager;
$siteManager = SiteManager::fromSystem();
$servers = $siteManager->getServers();
foreach ($servers as $server) {
echo 'Full server path: ' . $server->getPath() . PHP_EOL;
}
See the examples folder.
The test fixture tests/fixtures/sitemanager.xml
provides an example of all possible
options.
Folder structure of sitemanager.xml
π My Sites
β π Protocols
β βββ βοΈ azure-blob-storage.example.com
β βββ βοΈ azure-file-storage.example.com
β βββ βοΈ backblaze-b2.example.com
β βββ βοΈ box.example.com
β βββ βοΈ dropbox.example.com
β βββ π ftp.example.com - explicit ftp over tls
β βββ π ftp.example.com - explicit ftp over tls if available
β βββ π ftp.example.com - implicit ftp over tls
β βββ π ftp.example.com - plain ftp
β βββ π google-cloudstorage.example.com
β βββ βοΈ google-drive.example.com
β βββ βοΈ onedrive.example.com
β βββ βοΈ openstack-swift.example.com
β βββ βοΈ rackspace-cloud-storage.example.com
β βββ βοΈ s3.example.com
β βββ π sftp.example.com
β βββ π webdav.example.com - http
β βββ π webdav.example.com - https
β π Settings
β β π Advanced
β β βββ π _default
β β β π Adjusted server time
β β β βββ π minus 1 hour
β β β βββ π plus 1 hour
β β β βββ π plus 30 minutes
β β β π Bypass proxy
β β β βββ π disabled
β β β βββ π enabled
β β β π Directory comparison
β β β βββ π disabled
β β β βββ π enabled
β β β π Local directory
β β β βββ π local directory - Unix
β β β βββ π local directory - Windows
β β β π Remote directory
β β β βββ π remote directory - Unix
β β β βββ π remote directory - Windows
β β β π Server type
β β β βββ π cygwin
β β β βββ π default
β β β βββ π dos with back slashes
β β β βββ π dos with forward slashes
β β β βββ π doslike
β β β βββ π hp nonstop
β β β βββ π mvs
β β β βββ π unix
β β β βββ π vms
β β β βββ π vxworks
β β β βββ π zvm
β β β π Synchronized browsing
β β β βββ π disabled
β β β βββ π enabled
β β π Charset
β β βββ π autodetect
β β βββ π custom charset - utf16
β β βββ π force utf8
β β π General
β β β π Background color
β β β βββ π none
β β β βββ π red
β β β π Comments
β β β βββ π no comments
β β β βββ π with comments
β β β π Custom port
β β β βββ π custom port 8080
β β β βββ π default port
β β π Transfer Settings
β β βββ π transfer mode - 6 limit
β β βββ π transfer mode - Active
β β βββ π transfer mode - Default
β β βββ π transfer mode - No limit
β β βββ π transfer mode - Passive
β π Various
β βββ π Special !"#Β€%&()=<>
β βββ π Utf8 ππ’π«
The Server
class represents a single server configuration from the FileZilla sitemanager.xml
file. It provides
access to all attributes of a server, including its host, protocol, directories, and more.
Method | Returns | Description |
---|---|---|
getHost() |
string | Get the server's hostname or IP address. |
getPort() |
int | Get the server's port number. |
getProtocol() |
int | Get the server's protocol (ServerProtocol enum ). |
getLogonType() |
int | Get the server's logon type (LogonType enum ). |
getUser() |
?string | Get the username for authentication (nullable). |
getPassword() |
?string | Get the password for authentication (nullable). |
getKeyFile() |
?string | Get the path to the server's private key file (nullable). |
getTimezoneOffset() |
?int | Get the server's timezone offset (nullable). |
getPassiveMode() |
?string | Get the server's passive mode (PassiveMode enum , nullable). |
getMaximumMultipleConnections() |
?int | Get the maximum concurrent connections (nullable). |
getEncodingType() |
?string | Get the encoding type (CharsetEncoding enum , nullable). |
getCustomEncoding() |
?string | Get the custom encoding if the encoding type is custom. |
getBypassProxy() |
?bool | Check whether the server bypasses the proxy (nullable). |
getType() |
int | Get the server's type (ServerType enum ). |
getName() |
string | Get the name of the server as it appears in FileZilla. |
getComments() |
?string | Get the server's comments (nullable). |
getLocalDirectory() |
?string | Get the initial local directory for the server (nullable). |
getRemoteDirectory(string $default = null, bool $useRootPrefix = true) |
?string | Parse and return the server's remote directory (nullable). |
getSynchronizedBrowsing() |
?bool | Check whether synchronized browsing is enabled (nullable). |
getDirectoryComparison() |
?bool | Check whether directory comparison is enabled (nullable). |
getColour() |
int | Get the background color. |
getColor() |
?string | Alias for getColour() (nullable). |
The Folder
class represents a collection of Server
and/or Folder
objects, allowing for recursive structures of
servers and folders.
Method | Returns | Description |
---|---|---|
getName() |
string | Get the name of the folder. |
getChildren(bool $recursive, ?string $filter) |
Server[]/Folder[] | Get all children in the folder, optionally recursive and filtered by type. |
countServers(bool $recursive) |
int | Count the number of servers in the folder, optionally including subfolders. |
countFolders(bool $recursive) |
int | Count the number of folders in the folder, optionally including subfolders. |
getServers(bool $recursive) |
Server[] | Get all servers in the folder, optionally including subfolders. |
getFolders(bool $recursive) |
Folder[] | Get all folders in the folder, optionally including subfolders. |
getServer(string $serverPath) |
Server | Get a specific server by its path. |
getFolder(string $folderPath) |
Folder | Get a specific folder by its path. |
getChildPath(string $childName, ?string $childPath) |
string | Construct a full path for a child within the folder. |
The SiteManager
class extends Folder
, inheriting all of its functionality, and represents the root structure of
FileZilla's server and folder configuration as defined in the sitemanager.xml
file. In addition to managing nested
folders and servers, it provides access to metadata about the configuration file itself.
Method | Returns | Description |
---|---|---|
SiteManager::fromSystem() |
SiteManager | Create a SiteManager instance from the system's default configuration. |
getVersion() |
string | Get the version of the sitemanager.xml file. |
getPlatform() |
string | Get the platform specified in the sitemanager.xml file. |
Enum Class | Description |
---|---|
CharsetEncoding |
Charset encodings (Auto, UTF-8 or Custom) |
Colour |
Background colours (e.g. Red, Green, Blue). |
LogonType |
User authentication types (e.g., Normal, Anonymous). |
PassiveType |
The PasvMode setting (MODE_DEFAULT, MODE_ACTIVE or MODE_PASSIVE) |
ServerProtocol |
Server protocols like FTP, SFTP, FTPS, etc. |
ServerType |
Server types like Unix, DOS, etc. |
All enum classes have Enum::toCamelCase($value)
as well as Enum::getConstantName($value)
methods.
FileZilla Field | Attribute | Casting | Note |
---|---|---|---|
Host | host | string | Required |
Port | port | int | |
Protocol | protocol | int | |
Type | type | int | |
User | user | string | Required |
Pass | password | string | Required. Base64 encoded if encoding="base64" |
Keyfile | keyFile | string | Required |
Colour | colour | int | |
Logontype | logonType | int | |
TimezoneOffset | timezoneOffset | int | |
PasvMode | passiveMode | string | Required |
MaximumMultipleConnections | maximumMultipleConnections | int | |
EncodingType | encodingType | string | Required |
BypassProxy | bypassProxy | bool | |
Name | name | string | Required |
Comments | comments | string | Required |
LocalDir | localDirectory | string | Required |
RemoteDir | remoteDirectory | string | Required |
SyncBrowsing | synchronizedBrowsing | bool | |
DirectoryComparison | directoryComparison | bool | |
CustomEncoding | customEncoding | string | Required |
Contributions are welcome! Please submit a pull request or open an issue if you find a bug or have an idea for an enhancement.
This library is open-sourced under the MIT license.
- Author: JalsoeDesign
If you find this library useful, feel free to β the repository or share your feedback!