Search by

There is no license information available for the latest version (1.5.0) of this package.

File Managment in PHP.

Package info

github.com/ali-eltaweel/files

pkg:composer/ali-eltaweel/files

Statistics

Installs: 52

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

1.5.0 2025-11-24 09:43 UTC

This package is auto-updated.

Last update: 2026-09-24 11:41:36 UTC


README

File Managment in PHP

Installation

Install files via Composer:

composer require ali-eltaweel/files

Usage

Creating Files Objects

Instances of the File abstract class can be created using the File::make() which looks for the file type and returns the appropriate class instance, or by directly instantiating a concrete File class.

use Files\{ Directory, File, RegularFile };

$file = File::make('path/to/file');
$file = new RegularFile('path/to/file');

$dir = File::make('path/to/dir');
$dir = new Directory('path/to/dir');

Available File Types

  • Fifo
  • CharacterDevice
  • Directory
  • RegularFile
  • Symlink

File Properties

Property Type Get Set
path string ✅ ❌
uid string | integer ✅ ✅
gid string | integer ✅ ✅
permissions integer ✅ ✅
mode integer ✅ ✅
atime integer ✅ ✅
ctime integer ✅ ❌
mtime integer ✅ ✅
inode integer ✅ ❌
size integer ✅ ❌
type FileType ✅ ❌
stat Stat ✅ ❌

RegularFile Properties

Property Type Get Set
content string ✅ ✅

Link Properties

Property Type Get Set
targetGid string | integer ✅ ✅
targetUid string | integer ✅ ✅
target ?File ✅ ❌
finalTarget ?File ✅ ❌

File Methods

  • copy
copy(Path|string $target): bool
  • link
link(Path|string $target): bool
  • symlink
symlink(Path|string $target): bool
  • rename
rename(Path|string $target): bool
  • touch
touch(?int $mtime = null, ?int $atime = null): bool
  • remove
remove(): bool
  • open
open(): Handles\Handle

RegularFile Methods

  • transaction
transaction(callable $work, string $mode = 'r', Lock $lock = Lock::Exclusive): mixed
  • setContent
setContent(string $content): int
  • getContent
getContent(): ?string

Directory Methods

  • mkdir
mkdir(Path|string $name, int $permissions = 0777, bool $recursive = false): ?Directory
  • remove
remove(bool $force = false): bool
  • foreachChild
foreachChild(callable $callback): void

Link Methods

  • chgrpTarget
chgrpTarget(string|int $group): bool
  • chownTarget
chownTarget(string|int $user): bool
  • readlink
readlink(): ?File
  • readlinkRecursively
readlinkRecursively(): ?File