PHP code example of falc / flysystem-local-symlink-plugin

1. Go to this page and download the library: Download falc/flysystem-local-symlink-plugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

falc / flysystem-local-symlink-plugin example snippets


use Falc\Flysystem\Plugin\Symlink\Local as LocalSymlinkPlugin;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Filesystem;

$filesystem = new Filesystem(new LocalAdapter('/'));

$filesystem->addPlugin(new LocalSymlinkPlugin\Symlink());

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

$filesystem->addPlugin(new LocalSymlinkPlugin\DeleteSymlink());

$success = $filesystem->deleteSymlink('/tmp/symlink');

$filesystem->addPlugin(new LocalSymlinkPlugin\IsSymlink());

$isSymlink = $filesystem->isSymlink('/tmp/symlink');

use Falc\Flysystem\Plugin\Symlink\Local as LocalSymlinkPlugin;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Filesystem;

$filesystem = new Filesystem(new LocalAdapter('/home/falc'));
$filesystem->addPlugin(new LocalSymlinkPlugin\Symlink());
$filesystem->addPlugin(new LocalSymlinkPlugin\IsSymlink());
$filesystem->addPlugin(new LocalSymlinkPlugin\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');