PHPackages                             phuxtil/splfileinfo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. phuxtil/splfileinfo

ActiveLibrary[File &amp; Storage](/categories/file-storage)

phuxtil/splfileinfo
===================

SplFileInfo compatible implementation that allows to work with virtual (non existing) files

3.0.0(4y ago)015.1k↓100%[1 PRs](https://github.com/oliwierptak/phuxtil-splfileinfo/pulls)1MITPHPPHP ^8CI passing

Since Jun 16Pushed 3mo agoCompare

[ Source](https://github.com/oliwierptak/phuxtil-splfileinfo)[ Packagist](https://packagist.org/packages/phuxtil/splfileinfo)[ RSS](/packages/phuxtil-splfileinfo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (7)Used By (1)

phuxtil-splfileinfo
===================

[](#phuxtil-splfileinfo)

`VirtualSplFileInfo` allows to use non existing (virtual) paths and still be able to perform all file operations like `getSize()`, `isFile()`, `getOnwer()`, etc, and get predefined results.

It has setters support, and helper methods like `isVirtual()`, `toArray()`, `fromArray()`, `fromSplFileInfo()`.

### Installation

[](#installation)

```
composer require phuxtil/splfileinfo
```

*Note*: Use v1.x for compatibility with PHP v7.0.x. *Note*: Use v2.x for compatibility with PHP v7.2+

### Usage

[](#usage)

#### Create virtual file info.

[](#create-virtual-file-info)

```
$path = '/tmp/not-yet/existing-path';
$virtualInfo = new VirtualSplFileInfo($path);
```

Only PathInfo data is set at this point.

```
$virtualInfo->getPathname();  # /tmp/not-yet/existing-path
$virtualInfo->getPath();      # /tmp/not-yet
...
```

The rest of the data can be updated with setters.

```
$virtualInfo->setSize(120);
$virtualInfo->setATime(time());
$virtualInfo->setPerms(0775);
...
```

*Note: All properties besides PathInfo are set to -1 by default.*

#### Check if resource is virtual.

[](#check-if-resource-is-virtual)

```
$virtualInfo->getType();      # virtual
$virtualInfo->isVirtual();    # true
```

#### Update virtual file info with real resource data

[](#update-virtual-file-info-with-real-resource-data)

```
@mkdir($path);

$virtualInfo->fromSplFileInfo(new SplFileInfo($path));

$virtualInfo->isVirtual(); # false
```

`VirtualFileInfo` vs `\SplFileInfo`.

```
$splInfo = SplFileInfo {
  path: "/tmp/not-yet"
  filename: "existing-path"
  basename: "existing-path"
  pathname: "/tmp/not-yet/existing-path"
  extension: ""
  realPath: "/tmp/not-yet/existing-path"
  aTime: 2019-06-15 22:07:47
  mTime: 2019-06-15 22:07:47
  cTime: 2019-06-15 22:07:47
  inode: 10248205
  size: 64
  perms: 040755
  owner: 0
  group: 0
  type: "dir"
  writable: true
  readable: true
  executable: true
  file: false
  dir: true
  link: false
}

$virtualInfo = Phuxtil\SplFileInfo\VirtualSplFileInfo {
  path: "/tmp/not-yet"
  filename: "existing-path"
  basename: "existing-path"
  pathname: "/tmp/not-yet/existing-path"
  extension: ""
  realPath: "/tmp/not-yet/existing-path"
  aTime: 2019-06-15 22:07:47
  mTime: 2019-06-15 22:07:47
  cTime: 2019-06-15 22:07:47
  inode: 10248205
  size: 64
  perms: 040755
  owner: 0
  group: 0
  type: "dir"
  writable: true
  readable: true
  executable: true
  file: false
  dir: true
  link: false
}

```

### Extra methods

[](#extra-methods)

#### isVirtual(): bool

[](#isvirtual-bool)

Returns true if the and does not really exist.

*Note: isReadable(), isFile(),... etc, can return true, even if the resource does not exist.*

#### fromSplFileInfo(\\SplFileInfo $info)

[](#fromsplfileinfosplfileinfo-info)

```
$path = '/tmp/not-yet/existing-file.txt';
$virtualInfo = new VirtualSplFileInfo($path);
// ... do stuff

// create resource later
file_put_contents($path, 'Lorem Ipsum');

// update virtual file info
$virtualInfo->fromSplFileInfo(new SplFileInfo($path));
```

#### toArray(): array

[](#toarray-array)

```
$info = new VirtualSplFileInfo('/tmp/not-yet/existing-path');
$data = $info->toArray();
```

#### fromArray(array $data)

[](#fromarrayarray-data)

```
$info = new VirtualSplFileInfo('/tmp/not-yet/existing-path');
$info->fromArray(
    [
        'aTime' => 123,
        'mTime' => 456,
        'cTime' => 789,
        'inode' => 222,
        'size' => 333,
        'perms' => 0755,
        'owner' => 1,
        'group' => 2,
        'type' => 'dir',
        'writable' => true,
        'readable' => true,
        'executable' => true,
        'file' => false,
        'dir' => true,
        'link' => false,
    ]
);
```

#### Setter support

[](#setter-support)

You can use setters for all properties besides `PathInfo`, which is resolved by default in `\SplFileInfo`. The resource does not have to yet exist for those methods to work.

Properties with setters:

```
realPath
aTime
mTime
cTime
inode
size
perms
owner
group
type
writable
readable
executable
file
dir
link
linkTarget

```

#### Default values

[](#default-values)

All values besides `PathInfo` are set to `-1` by default.

#### TDD

[](#tdd)

See [tests](https://github.com/oliwierptak/phuxtil-splfileinfo/blob/master/tests/Functional/SplFileInfo/SplFileInfoSimpleTest.php) for more examples.

###  Health Score

41

—

FairBetter than 88% of packages

Maintenance57

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~234 days

Total

4

Last Release

1816d ago

Major Versions

1.0.1 → 2.0.02019-12-01

2.0.0 → 3.0.02021-05-18

PHP version history (3 changes)1.0.0PHP ^7

2.0.0PHP ^7.2

3.0.0PHP ^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/73a4cc056d2b09189dda46d01b76e71161dd9b75a226230bed6bec8f414d1cf8?d=identicon)[oliwierptak](/maintainers/oliwierptak)

---

Top Contributors

[![oliwierptak](https://avatars.githubusercontent.com/u/495101?v=4)](https://github.com/oliwierptak "oliwierptak (29 commits)")

---

Tags

filefilesystemphpsplfileinfoutilutilityvirtual

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phuxtil-splfileinfo/health.svg)

```
[![Health](https://phpackages.com/badges/phuxtil-splfileinfo/health.svg)](https://phpackages.com/packages/phuxtil-splfileinfo)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M123](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M61](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
