Adapters

Adapters allow you to connector various services such as Amazon S3 for storage.

Standard Adapters

InMemoryAdapter

In Memory Adapter does not write anything to disk but keeps them in memory.

<?php

use SonsOfPHP\Component\Filesystem\Adapter\InMemoryAdapter;

$adapter = new InMemoryAdapter();

NativeAdapter

Read/write files to disk.

<?php

use SonsOfPHP\Component\Filesystem\Adapter\NativeAdapter;

$adapter = new NativeAdapter(
    prefix: '/tmp',
);

NullAdapter

This adapter does not read or write anything. Mainly used for testing.

Special Adapters

Special adapters are used in various use cases.

ChainAdapter

This allows you to use multiple adapters together.

When writing a file, it will write to ALL adapters.

When getting a file, it will return the file on the first adapter that has that file.

When deleting a file, it will delete them from ALL adapters.

ReadOnlyAdapter

This ONLY allows you to read files from a filesystem. You cannot write anything.

WormAdapter

This adapters allows you to Write Once, Read Many (WORM). Once a file has been written, it CANNOT be modified.

Additional Adapters

AWS S3

Last updated

Was this helpful?