league/flysystem-adapter-decorator

A base implementation of a flysystem adapter decorator

Maintainers

👁 frankdejonge

Package info

github.com/thephpleague/flysystem-adapter-decorator

pkg:composer/league/flysystem-adapter-decorator

Statistics

Installs: 139 211

Dependents: 2

Suggesters: 0

Stars: 17

Open Issues: 1

1.0.0 2015-01-21 22:19 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 72178f148bdd1bec16d9f25bf8f7ac32795bfcc7

  • Frank de Jonge <info.woop@frenky.net>

This package is auto-updated.

Last update: 2026-06-06 12:29:53 UTC


README

This package provides a default adapter decorator. In most cases decorators only influence a particular part of the interface. The trait provided by this package provides the default implementation for the methods which the decorator is not concerned with.

Installation

composer require league/flysystem-adapter-decorator

Creating Decorators

<?php

use League\Flysystem\AdapterDecorator\DecoratorTrait;
use League\Flysystem\AdapterInterface;
use League\Flysystem\Config;

class MyDecorator implements AdapterInterface
{
 use DecoratorTrait;

 protected $adapter;

 public function __construct(AdapterInterface $adapter)
 {
 $this->adapter = $adapter;
 }

 // Required method to implement
 protected function getDecoratedAdapter()
 {
 return $this->adapter;
 }

 // Add your decorator methods here...

 public function write($path, $contents, Config $config)
 {
 $contents = funky_encryption($contents);

 return $this->getDecoratedAdapter()->write($path, $contents, $config);
 }
}

Using Decorators

<?php

use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;

$adapter = new Local($root);
$decoratedAdapter = new MyDecorator($adapter);
$filesystem = new Filesystem($decoratedAdapter);
// Use the Flysystem as you normally would.