Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Flysystem Local Symlink Plugin

Requirements

Installation

Using composer:

composer require falc/flysystem-local-symlink-plugin

Or add it manually:

{
"require": {
"falc/flysystem-local-symlink-plugin": "1.*"
}
}

Usage

This plugin requires a Filesystem instance using the Local adapter.

useFalc\Flysystem\Plugin\Symlink\LocalasLocalSymlinkPlugin;
useLeague\Flysystem\Adapter\LocalasLocalAdapter;
useLeague\Flysystem\Filesystem;
$filesystem = newFilesystem(newLocalAdapter('/'));

Symlink

Use symlink($target, $symlink) to create a symlink.

$filesystem->addPlugin(newLocalSymlinkPlugin\Symlink());
$success = $filesystem->symlink('/tmp/some/target', '/tmp/symlink');

DeleteSymlink

Use deleteSymlink($symlink) to delete a symlink.

$filesystem->addPlugin(newLocalSymlinkPlugin\DeleteSymlink());
$success = $filesystem->deleteSymlink('/tmp/symlink');

IsSymlink

Use isSymlink($filename) to check if a file exists and is a symlink.

$filesystem->addPlugin(newLocalSymlinkPlugin\IsSymlink());
$isSymlink = $filesystem->isSymlink('/tmp/symlink');

Full and relative paths

The above examples show how to create symlinks using / as root and full paths. But it is possible to use relative paths too.

useFalc\Flysystem\Plugin\Symlink\LocalasLocalSymlinkPlugin;
useLeague\Flysystem\Adapter\LocalasLocalAdapter;
useLeague\Flysystem\Filesystem;
$filesystem = newFilesystem(newLocalAdapter('/home/falc'));
$filesystem->addPlugin(newLocalSymlinkPlugin\Symlink());
$filesystem->addPlugin(newLocalSymlinkPlugin\IsSymlink());
$filesystem->addPlugin(newLocalSymlinkPlugin\DeleteSymlink());
// Result: /home/falc/flytest -> /home/falc/projects/cli/flytest$filesystem->symlink('projects/cli/flytest', 'flytest');
// It is possible to check it or delete it in the same way:$isSymlink = $filesystem->isSymlink('flytest');
$filesystem->deleteSymlink('flytest');

About

Local symlink plugin for Flysystem.

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages