PHP code example of druc / flysystem-incremental-naming

1. Go to this page and download the library: Download druc/flysystem-incremental-naming 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/ */

    

druc / flysystem-incremental-naming example snippets

 php

use Druc\Flysystem\IncrementalNaming\IncrementedCopy;
use Druc\Flysystem\IncrementalNaming\IncrementedRename;
use Druc\Flysystem\IncrementalNaming\IncrementedPath;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;

;

$filesystem = new Filesystem($adapter);

// Filenames will be incremented when copying/renaming into a directory containing the same filename
$filesystem->incrementedCopy('mydir/file', 'other-dir/file'); // 'other-dir/file_1'
$filesystem->incrementedRename('mydir/file', 'other-dir/file'); // 'other-dir/file_1'

// This returns 'other-dir/file_2' if 'file' and 'file_1' are already present
$filesystem->getIncrementedPath('other-dir/file');