Skip to content

Commit

Permalink
Amend README example to cover commonly needed path normalizer configu…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
elazar committed Aug 14, 2024
1 parent 355caf9 commit 59a6bc3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,33 @@ These examples below aren't comprehensive, but should provide a basic understand
<?php

/**
* 1. Configure your Flysystem filesystem as normal.
* 1. Configure your Flysystem filesystem to use the Flystream path
* normalizer; see the "Path Normalization" section of this README for
* more details.
*/

use Elazar\Flystream\ServiceLocator;
use League\Flysystem\Filesystem;
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
use League\Flysystem\PathNormalizer;

$adapter = new InMemoryFilesystemAdapter;
$filesystem = new Filesystem($adapter);
$config = [ /* ... */ ];
$pathNormalizer = ServiceLocator::get(PathNormalizer::class);
$filesystem = new Filesystem($adapter, $config, $pathNormalizer);

/**
* 2. Register the filesystem with Flystream and associate it with a
* custom protocol (e.g. 'mem').
*/

use Elazar\Flystream\FilesystemRegistry;
use Elazar\Flystream\ServiceLocator;

$registry = ServiceLocator::get(FilesystemRegistry::class);
$registry->register('mem', $filesystem);

/**
* 3. Interact with the filesystem instance using the custom protocol.
* 3. Interact with the filesystem using the custom protocol.
*/

mkdir('mem://foo');
Expand Down

0 comments on commit 59a6bc3

Please sign in to comment.