1. Go to this page and download the library: Download infocyph/pathwise 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/ */
infocyph / pathwise example snippets
use Infocyph\Pathwise\FileManager\SafeFileReader;
$reader = new SafeFileReader('/path/to/file.txt');
// Line-by-line iteration
foreach ($reader->line() as $line) {
echo $line;
}
// JSON decoding with error handling
foreach ($reader->json() as $data) {
print_r($data);
}
use Infocyph\Pathwise\FileManager\SafeFileWriter;
$writer = new SafeFileWriter('/path/to/file.txt');
// Writing lines
$writer->line('Hello, World!');
// Writing JSON data
$writer->json(['key' => 'value']);
use Infocyph\Pathwise\FileManager\FileOperations;
$fileOps = new FileOperations('/path/to/file.txt');
// Check existence
if ($fileOps->exists()) {
echo 'File exists';
}
// Read content
echo $fileOps->read();
use Infocyph\Pathwise\FileManager\FileCompression;
$compression = new FileCompression('/path/to/archive.zip');
// Compress a directory
$compression->compress('/path/to/directory');
// Decompress
$compression->decompress('/path/to/extract/');
use Infocyph\Pathwise\DirectoryManager\DirectoryOperations;
$dirOps = new DirectoryOperations('/path/to/directory');
// Create a directory
$dirOps->create();
// List contents
$contents = $dirOps->listContents(detailed: true);
print_r($contents);
use Infocyph\Pathwise\Utils\PermissionsHelper;
// Get human-readable permissions
echo PermissionsHelper::getHumanReadablePermissions('/path/to/file');
// Check if writable
if (PermissionsHelper::canWrite('/path/to/file')) {
echo 'File is writable';
}