PHP code example of guillaumetissier / path-utilities

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

    

guillaumetissier / path-utilities example snippets


use Guillaumetissier\PathUtilities\Path;

$path = new Path('/path/to/file.txt');

// Basic information
echo $path->basename();  // file.txt
echo $path->extension(); // txt
echo $path->dirname();   // /path/to

// Parent directory
$parent = $path->parent();

// Check existence and type
if ($path->exists() && $path->isFile()) {
    echo "File exists!";
}

// File size
echo $path->size(); // in bytes

// Permissions
$permissions = $path->permissions();
echo $permissions->octal();     // e.g., 0644
echo $permissions->symbolic();  // e.g., rw-r--r--

// File times
$times = $path->times();
echo $times->modification()->format('Y-m-d H:i:s');