PHP code example of max-s-lab / php-local-filesystem

1. Go to this page and download the library: Download max-s-lab/php-local-filesystem 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/ */

    

max-s-lab / php-local-filesystem example snippets


$ php composer.phar 

$filesystem->writeToFile('file.txt', 'Test');

$filesystem->writeToFile('file.txt', 'Test', [
    'directoryPermissions' => 0777,
    'filePermissions' => 0666,
]);

$filesystem->deleteFile('file.txt');

$filesystem->copyFile('file.txt', 'directory/file.txt');

$filesystem->copyFile('file.txt', 'directory/file.txt', [
    'directoryPermissions' => 0777,
    'filePermissions' => 0666,
]);

$filesystem->moveFile('file.txt', 'directory/file.txt');

$filesystem->moveFile('file.txt', 'directory/file.txt', [
    'directoryPermissions' => 0777,
    'filePermissions' => 0666,
]);

$result = $filesystem->readFile('file.txt');

$result = $filesystem->readFileAsStream('file.txt');

$result = $filesystem->getFileSize('file.txt');

$result = $filesystem->getFileMimeType('file.txt');

$result = $filesystem->getFileLastModifiedTime('file.txt');

$result = $filesystem->prepareFullPath('file.txt');

$result = $filesystem->prepareFullPath('directory');

$result = filesystem->listPathnames('*');

$filesystem->setPermissions('file.txt', 0644);

$result = $filesystem->getPermissions('file.txt');

$result = $filesystem->getPermissions('directory');

$result = $filesystem->fileExists('file.txt');

$result = $filesystem->directoryExists('directory');