Download the PHP package infocyph/pathwise without Composer
On this page you can find all versions of the php package infocyph/pathwise. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package pathwise
Pathwise: File Management Made Simple
Pathwise is a robust PHP library designed for streamlined file and directory management. With features like safe reading/writing, metadata extraction, path utilities, compression, and permission management, it ensures a developer-friendly experience while handling complex file operations.
Table of Contents
- Introduction
- Prerequisites
- Installation
- Features Overview
- FileManager
- SafeFileReader
- SafeFileWriter
- FileOperations
- FileCompression
- DirectoryManager
- DirectoryOperations
- Utils
- PathHelper
- PermissionsHelper
- MetadataHelper
- Handy Functions
- File and Directory Utilities
- Support
- License
Prerequisites
- Language: PHP 8.2/+
Installation
Pathwise is available via Composer:
Requirements:
- PHP 8.2 or higher
- Optional Extensions:
ext-zip
: Required for compression features.ext-posix
: Required for permission handling.ext-xmlreader
andext-simplexml
: Required for XML parsing.
Features Overview
FileManager
The FileManager
module provides classes for handling files, including reading, writing, compressing, and general file operations.
SafeFileReader
A memory-safe file reader supporting various reading modes (line-by-line, binary chunks, JSON, CSV, XML, etc.) and iterator interfaces.
Key Features
- Supports multiple reading modes.
- Provides locking to prevent concurrent access issues.
- Implements
Countable
,Iterator
, andSeekableIterator
.
Usage Example
SafeFileWriter
A memory-safe file writer with support for various writing modes, including CSV, JSON, binary, and more.
Key Features
- Supports multiple writing modes.
- Ensures file locking and robust error handling.
- Tracks write operations and supports flush and truncate methods.
Usage Example
FileOperations
General-purpose file handling class for creating, deleting, copying, renaming, and manipulating files.
Key Features
- File creation and deletion.
- Append and update content.
- Rename, copy, and metadata retrieval.
Usage Example
FileCompression
Provides utilities for compressing and decompressing files using the ZIP format with optional password protection and encryption.
Key Features
- Compress files/directories.
- Decompress ZIP archives.
- Support for AES encryption and password-protected ZIPs.
Usage Example
DirectoryManager
The DirectoryManager
module offers tools for handling directory creation, deletion, and traversal.
DirectoryOperations
Provides comprehensive tools for managing directories, including creation, deletion, copying, and listing contents.
Key Features
- Create, delete, and copy directories.
- Retrieve directory size, depth, and contents.
- Supports recursive operations and filtering.
Usage Example
Utils
Utility classes for managing paths, permissions, and metadata.
PathHelper
Provides utilities for working with file paths, including joining, normalizing, and converting between relative and absolute paths.
Key Features
- Path joining and normalization.
- Convert between relative and absolute paths.
- Retrieve and manipulate file extensions.
Usage Example
PermissionsHelper
Handles file and directory permissions, ownership, and access control.
Key Features
- Retrieve and set permissions.
- Check read, write, and execute access.
- Retrieve and set ownership details.
Usage Example
MetadataHelper
Extracts metadata for files and directories, such as size, timestamps, MIME type, and more.
Key Features
- Retrieve file size and type.
- Compute checksums and timestamps.
- Get ownership and visibility details.
Usage Example
Handy Functions
File and Directory Utilities
Pathwise provides standalone utility functions to simplify common file and directory operations.
1. Get Human-Readable File Size
Formats a file size in bytes into a human-readable format (e.g., 1.23 KB
, 4.56 GB
).
Usage Example:
2. Check if a Directory is Empty
Checks whether the given directory contains any files or subdirectories.
Usage Example:
3. Delete a Directory Recursively
Deletes a directory and all its contents (files and subdirectories).
Usage Example:
4. Get Directory Size
Calculates the total size of a directory, including all its files and subdirectories.
Usage Example:
5. Create a Directory
Creates a directory (including parent directories) with specified permissions.
Usage Example:
6. List Files in a Directory
Lists all files in a directory, excluding subdirectories.
Usage Example:
7. Copy a Directory Recursively
Copies a directory and all its contents to a new location.
Usage Example:
Support
Having trouble? Create an issue!
License
Pathwise is licensed under the MIT License.