PHP code example of ichhabrecht / filesystem

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

    

ichhabrecht / filesystem example snippets


$fileidentity = new \IchHabRecht\Filesystem\Fileidentity();
if (!$fileidentity->canBeValidated('/path/to/file') || $fileidentity->isValid('/path/to/file')) {
    // Do something
}

$filemode = new \IchHabRecht\Filesystem\Filemode();
$filemode->setPermissions('/path/to/adjust', $settings);

// This sets file permissions to read and execute (5) and folder permissions to read, write and execute (7)
$settings = [
    'file' => '555',
    'folder' => '777',
];

// This ensures read and write access (6) for files, as well as write and execute access (3) for folders
$settings = [
    'file' => [
        'user' => 6,
        'group' => 6,
        'other' => 6,
    ],
    'folder' => [
        'user' => 3,
        'group' => 3,
        'other' => 3,
    ],
];

$filepath = new \IchHabRecht\Filesystem\Filepath('/', true);
$filepath->concatenate('/var/', 'www', 'vhosts'); // Returns '/var/www/vhosts'
$filepath->ensureDirectorySeparator('C:\\Users\\All Users\\Favorites'); // Returns 'C:/Users/All Users/Favorites'
$filepath->normalize('/var/www/./../../vhosts'); // Returns '/vhosts'