Documentation

Driver
in package
implements DriverInterface

Interfaces, Classes and Traits

DriverInterface
This class determines what behaviors a blob storage needs to define to be compatible with Spitfire.

Table of Contents

$path  : string
This "encages" the application, preventing it from writing outside the scope of the storage mechanism.
__construct()  : mixed
NOTE: The driver is not made aware of the scheme it's providing. It will only serve the data. If your driver needs access to the scheme, it's likely that it's not working the right way
atime()  : mixed
Returns the las access time of the blob. Please note that this may be affected by third party applications scanning your server's directories.
contains()  : mixed
Returns whether the collection contains an unexpired entry for the key provided.
delete()  : mixed
Removes the blob from the server. Drivers are allowed to perform advisory deletions, meaning that the data is not removed from the media it resides on immediately but marked as deleted instead.
length()  : int
Returns the size (in bytes) of a certain file on the file-system.
mime()  : mixed
Returns the mime content-type for the file provided. The system may use different mechanisms for detecting the content/type or may be returning an improper one.
mtime()  : mixed
Returns the unix timestamp the blob was modified at.
read()  : mixed
Reads the entire blob from the source device / service / network. This is a very convenient method for handling smaller blobs like text files or memcached keys.
readonly()  : mixed
Allows the driver to indicate that a certain key is read only and therefore not writable.
stream()  : IOStream
Allows the application to start streaming to the storage engine. This greatly increases the responsiveness of the application since it will receive control back in regular intervals.
url()  : mixed
Returns a public URL for the file. This allows users to download the file from a different server (eventually for a restricted amount of time)
write()  : mixed
Writes a blob to the collection. Please note that this method requires a Blob as it's second parameter, you can easily create a blob using the blob() function with a mime type and a string.

Properties

$path

This "encages" the application, preventing it from writing outside the scope of the storage mechanism.

private string $path

Methods

__construct()

NOTE: The driver is not made aware of the scheme it's providing. It will only serve the data. If your driver needs access to the scheme, it's likely that it's not working the right way

public __construct(mixed $dsn) : mixed
Parameters
$dsn : mixed

Configuration string for the driver

Return values
mixed

atime()

Returns the las access time of the blob. Please note that this may be affected by third party applications scanning your server's directories.

public atime(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

contains()

Returns whether the collection contains an unexpired entry for the key provided.

public contains(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

delete()

Removes the blob from the server. Drivers are allowed to perform advisory deletions, meaning that the data is not removed from the media it resides on immediately but marked as deleted instead.

public delete(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

length()

Returns the size (in bytes) of a certain file on the file-system.

public length(string $key) : int
Parameters
$key : string
Tags
todo

Check the behavior of this method with stuff like /dev/one or similar

Return values
int

mime()

Returns the mime content-type for the file provided. The system may use different mechanisms for detecting the content/type or may be returning an improper one.

public mime(mixed $key) : mixed

Do not use this to replace validating the contents of a file. A file reported as, for example, jpeg by the storage driver may actually be a PDF to a client's computer.

Parameters
$key : mixed
Return values
mixed

mtime()

Returns the unix timestamp the blob was modified at.

public mtime(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

read()

Reads the entire blob from the source device / service / network. This is a very convenient method for handling smaller blobs like text files or memcached keys.

public read(mixed $key) : mixed

This is likely to have your server run out of memory if you're managing big files, for that you should refer to the stream() method.

This method must be implemented in a synchronous manner. It does not support asynchronous calls.

Parameters
$key : mixed
Return values
mixed

readonly()

Allows the driver to indicate that a certain key is read only and therefore not writable.

public readonly(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

stream()

Allows the application to start streaming to the storage engine. This greatly increases the responsiveness of the application since it will receive control back in regular intervals.

public stream(mixed $key) : IOStream

This can ensure that a long file transfer does not prevent the system from attending other tasks, and the application can still inform the user about progress.

Parameters
$key : mixed
Return values
IOStream

url()

Returns a public URL for the file. This allows users to download the file from a different server (eventually for a restricted amount of time)

public url(mixed $key, mixed $ttl) : mixed

This is extremely helpful in scenarios where the storage is not on the websever but on something like Cloudy, S3 or Digital Ocean. You can just have the server generate a link that the user can use to download the file.

The link may be generated for a single use, or just as many as the user wishes. Your server does not need to host the file.

Parameters
$key : mixed
$ttl : mixed
Return values
mixed

write()

Writes a blob to the collection. Please note that this method requires a Blob as it's second parameter, you can easily create a blob using the blob() function with a mime type and a string.

public write(mixed $key, mixed $contents[, mixed $ttl = null ]) : mixed
Parameters
$key : mixed
$contents : mixed
$ttl : mixed = null

Time in seconds until the key expires and the blob should be freed

Return values
mixed

Search results