PHPackages                             plumphp/plum-file - 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. plumphp/plum-file

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

plumphp/plum-file
=================

Additional converters and file to work with files in Plum.

v0.2.1(11y ago)327MITPHPPHP &gt;=5.4

Since Mar 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/plumphp/plum-file)[ Packagist](https://packagist.org/packages/plumphp/plum-file)[ RSS](/packages/plumphp-plum-file/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (5)Versions (6)Used By (0)

 [![Plum](https://camo.githubusercontent.com/a81342cbfd6f64a484988488ad37bbd0e665d0f14f65ec655ae986097447bfb6/687474703a2f2f63646e2e666c6f7269616e2e65632f706c756d2d6c6f676f2e737667)](https://camo.githubusercontent.com/a81342cbfd6f64a484988488ad37bbd0e665d0f14f65ec655ae986097447bfb6/687474703a2f2f63646e2e666c6f7269616e2e65632f706c756d2d6c6f676f2e737667)
==================================================================================================================================================================================================================================================================================================================================================================

[](#----)

> PlumFile includes converters and filters to work with files in Plum. Plum is a data processing pipeline for PHP.

[![Build Status](https://camo.githubusercontent.com/83d1e54eb4ddcd873480d8f480f142aae389b99173e8b15a0ac3e19e09abad61/68747470733a2f2f7472617669732d63692e6f72672f706c756d7068702f706c756d2d66696c652e737667)](https://travis-ci.org/plumphp/plum-file)[![Windows Build status](https://camo.githubusercontent.com/da7999fa07a94e33697fa9a491f62cfc250ce673d714c6f6909703858d29e448/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f657967636d75643464653836363632393f7376673d74727565)](https://ci.appveyor.com/project/florianeckerstorfer/plum-file)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5caff6609d81d6f7eccda64003627b05830de7b7e4d8144120b4de00b3b60aa9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f706c756d7068702f706c756d2d66696c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/plumphp/plum-file/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/4384ffb3e1150fa9cb7cc60dcfd3fbe27245e1a82dad4f14fda6379ae1919975/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f706c756d7068702f706c756d2d66696c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/plumphp/plum-file/?branch=master)[![StyleCI](https://camo.githubusercontent.com/0bae0bc96a1d4adcda39a56d1cd94981a7ed3dff5ab69d6604da87bc73eefe8a/68747470733a2f2f7374796c6563692e696f2f7265706f732f33303731333730342f736869656c64)](https://styleci.io/repos/30713704)

Developed by [Florian Eckerstorfer](https://florian.ec) in Vienna, Europe.

Installation
------------

[](#installation)

You can install Plum using [Composer](http://getcomposer.org).

```
$ composer require plumphp/plum-file
```

Usage
-----

[](#usage)

Please refer to the [Plum documentation](https://github.com/plumphp/plum/blob/master/docs/index.md) for more information about Plum in general.

### `FileExtensionFilter`

[](#fileextensionfilter)

`Plum\PlumFile\FileExtensionFilter` checks if the file extension of a file name matches.

```
use Plum\PlumFile\FileExtensionFilter;

$filter = new FileExtensionFilter('md');
$filter->filter('README.md'); // -> true
$filter->filter('README.html'); // -> false
```

If the item is are more complex structure, for example, an array or an object `FileExtensionFilter` uses Symfonys [PropertyAccess](http://symfony.com/doc/current/components/property_access/introduction.html) to retrieve the filename from the item. You can pass the path to the property as the second argument to the constructor.

```
use Plum\PlumFile\FileExtensionFilter;

$filterArray = new FileExtensionFilter('md', '[filename]');
$filterArray->filter(['filename' => 'README.md']); // -> true
$filterArray->filter(['filename' => 'README.html']); // -> false

$item = new stdClass();
$item->filename = 'README.md';
$filterObject = new FileExtensionFilter('md', 'filename');
$filterObject->filter($item); // -> true
$item->filename = 'README.html';
$filterObject->filter($item); // -> false
```

The extension passed to the constructor can also be an array. The filter returns `true` if the given item matches any of the extensions in the array.

```
$filter = new FileExtensionFilter(['md', 'html']);
$filter->filter('file.md');   // -> true
$filter->filter('file.html'); // -> false
$filter->filter('file.csv`);  // -> false
```

Just like the [`FileExtensionFilter`](#fileextensionfilter) the `ModificationTimeFilter` uses the Property Access component to retrieve the filename. You can pass the path to the property as second argument to the constructor. The file can be either a string or an instance of `SplFileInfo`.

`ModificationTimeFilter`
========================

[](#modificationtimefilter)

The `Plum\PlumFile\ModificationTimeFilter` returns if a file was modified before and/or after a certain time.

```
use Plum\PlumFile\ModificationTimeFilter;

$after = new ModificationTimeFilter(['after' => new DateTime('-3 days')]);
$after->filter('modified-2-days-ago.txt'); // -> true
$after->filter('modified-4-days-ago.txt'); // -> false

$before = new ModificationTimeFilter(['before' => new DateTime('-3 days')]);
$before->filter('modified-4-days-ago.txt'); // -> true
$before->filter('modified-2-days-ago.txt'); // -> false

$range = new ModificationTimeFilter(['after' => new DateTime('-6 days'), 'before' => new DateTime('-3 days')]);
$range->filter('modified-4-days-ago.txt'); // -> true
$range->filter('modified-8-days-ago.txt'); // -> false
$range->filter('modified-2-days-ago.txt'); // -> false
```

### `FileGetContentsConverter`

[](#filegetcontentsconverter)

The `Plum\PlumFile\FileGetContentsConverter` takes a `SplFileInfo` object or a filename and returns the content of the file.

```
use Plum\PlumFile\FileGetContentsConverter;

$converter = new FileGetContentsConverter();
$converter->convert('foo.txt'); // -> 'content of foo.txt'
```

If the item is a more complex structure it is possible to define the [Vale](https://github.com/cocur/vale) accessor property for both the filename and the content.

```
use Plum\PlumFile\FileGetContentsConverter;

$converter = new FileGetContentsConverter('file', 'content');
$converter->convert(['file' => foo.txt']);
// -> ['file' => 'foo.txt', 'content' => content of foo.txt']
```

Change Log
----------

[](#change-log)

### Version 0.2.1 (28 April 2015)

[](#version-021-28-april-2015)

- Fix Plum version

### Version 0.2 (22 April 2015)

[](#version-02-22-april-2015)

- Set Plum version to 0.2

### Version 0.1 (18 March 2015)

[](#version-01-18-march-2015)

- Initial release

License
-------

[](#license)

The MIT license applies to plumphp/plum-finder. For the full copyright and license information, please view the LICENSE file distributed with this source code.

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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 ~10 days

Total

5

Last Release

4060d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a80f9fc61cd3a7d7779e8f120b458ca4d18fdd885d719bb77d3379b96bf714d9?d=identicon)[florianeckerstorfer](/maintainers/florianeckerstorfer)

---

Top Contributors

[![florianeckerstorfer](https://avatars.githubusercontent.com/u/149201?v=4)](https://github.com/florianeckerstorfer "florianeckerstorfer (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/plumphp-plum-file/health.svg)

```
[![Health](https://phpackages.com/badges/plumphp-plum-file/health.svg)](https://phpackages.com/packages/plumphp-plum-file)
```

###  Alternatives

[glicer/sync-sftp

Sync local files with ftp server

212.7k](/packages/glicer-sync-sftp)[venveo/craft-compress

Create smart zip files from Craft assets on the fly

124.7k](/packages/venveo-craft-compress)

PHPackages © 2026

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