PHP code example of phuxtil / splfileinfo

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

    

phuxtil / splfileinfo example snippets


$path = '/tmp/not-yet/existing-path';
$virtualInfo = new VirtualSplFileInfo($path);

$virtualInfo->getPathname();  # /tmp/not-yet/existing-path
$virtualInfo->getPath();      # /tmp/not-yet
...

$virtualInfo->setSize(120);
$virtualInfo->setATime(time());
$virtualInfo->setPerms(0775);
...

$virtualInfo->getType();      # virtual
$virtualInfo->isVirtual();    # true
 
@mkdir($path);

$virtualInfo->fromSplFileInfo(new SplFileInfo($path));

$virtualInfo->isVirtual(); # false
 php
$path = '/tmp/not-yet/existing-file.txt';
$virtualInfo = new VirtualSplFileInfo($path);
// ... do stuff

// create resource later
file_put_contents($path, 'Lorem Ipsum');

// update virtual file info 
$virtualInfo->fromSplFileInfo(new SplFileInfo($path));
 php
$info = new VirtualSplFileInfo('/tmp/not-yet/existing-path');
$data = $info->toArray();