Error: Failed to load processor TOC
No macro or processor named 'TOC' found

Documentation

Overview

MogileFS for PHP comes with two classes: MogileFs, the client class and MogileFsException, a specific exception class used to throw errors.

Basic usage

Sending and retrieving a file

<?php
$client = new MogileFs();
$client->connect('host', 6001, 'myDomain');

$client->put('path/to/file', 'myFile', 'myClass');
$metadata = $client->get('myFile');

$content = file_get_contents($metadata['path1']);

MogileFs

Working with tracker connections

Connecting to a tracker

bool MogileFs::connect(string host, int port, string domain, [int timeout])
    throws MogileFsException

Connect to a server using the connect-method. The default port for MogileFS is 6001 and the timeout parameter is optional and can be omitted.

Disconnecting from a tracker

bool MogileFs::disconnect()
bool MogileFs::close()

To shutdown a server connection, use the disconnect- or close-method. If it is omitted it will be done automatically in the destructor.

Managing MogileFS domains

MogileFS organizes its files into a flat hierarchy of domains. Each file key must be unique per domain. Domains can be managed with a tool like  mogadm or with the PHP binding.

Creating domains

array MogileFs::createDomain(string domain)
    throws MogileFsException

Creating a domain could not be simpler: just pass the name of the domain as a string to the createDomain-method. If a domain of the same name already exists, an exception of type MogileFsException is thrown.

Retrieving a list of domains

array MogileFs::getDomains()
    throws MogileFsException

The method getDomains returns a hash of domains. getDomains expects no argument.

Deleting a domain

array MogileFs::deleteDomain(string domain)

Deleting a domain is as simple as creating a class. Just a single param - the domain name - is required.