ali-eltaweel / files
File Managment in PHP.
Installs: 29
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/ali-eltaweel/files
Requires
- php: ^8.1
- ali-eltaweel/codecs: ^1.2
- ali-eltaweel/computed-properties: ^1.0.1
- ali-eltaweel/lazy-props: ^1.0.0
- ali-eltaweel/logger: ^2.0
- ali-eltaweel/virtual-props: ^1.0.0
This package is auto-updated.
Last update: 2025-11-08 16:21:24 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