PHPackages                             holyshared/peridot-temporary-plugin - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. holyshared/peridot-temporary-plugin

ActiveLibrary[Testing &amp; Quality](/categories/testing)

holyshared/peridot-temporary-plugin
===================================

Temporary file / directory plugin for peridot-php

1.0.5(10y ago)01.2k6MITPHPPHP &gt;=5.5.0

Since Mar 19Pushed 10y agoCompare

[ Source](https://github.com/holyshared/peridot-temporary-plugin)[ Packagist](https://packagist.org/packages/holyshared/peridot-temporary-plugin)[ RSS](/packages/holyshared-peridot-temporary-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (9)Versions (19)Used By (6)

peridot-temporary-plugin
========================

[](#peridot-temporary-plugin)

It provides an api to create a temporary directory or file.
Directory of file will be deleted at the end of the test.

[![Build Status](https://camo.githubusercontent.com/da21279f205a0b077d7c356678939e54edb50f7264ec257e2abc9e2747a078b9/68747470733a2f2f7472617669732d63692e6f72672f686f6c797368617265642f70657269646f742d74656d706f726172792d706c7567696e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/holyshared/peridot-temporary-plugin)[![HHVM Status](https://camo.githubusercontent.com/c39bb840a5f2d9d99426079883402c1582524b2788f05a9072712955f40d3f86/687474703a2f2f6868766d2e683463632e64652f62616467652f686f6c797368617265642f70657269646f742d74656d706f726172792d706c7567696e2e737667)](http://hhvm.h4cc.de/package/holyshared/peridot-temporary-plugin)[![Coverage Status](https://camo.githubusercontent.com/93c62a0c195b19bdb669d0ca55729c22e21ad839f655561ed1e16435e95e39eb/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f686f6c797368617265642f70657269646f742d74656d706f726172792d706c7567696e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/r/holyshared/peridot-temporary-plugin?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5aa9832dbcffe271303e68036fb664bc97205cc4f183846f1215903ca343034e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f686f6c797368617265642f70657269646f742d74656d706f726172792d706c7567696e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/holyshared/peridot-temporary-plugin/?branch=master)[![Dependency Status](https://camo.githubusercontent.com/ee8ba64ca45ea5cdca54fdd2d59e0c92fda8c3008d80832d0bb50d6482af59c8/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3535316662646130393731663738316334383030303334662f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/551fbda0971f781c4800034f)

Basic usage
-----------

[](#basic-usage)

First will first register the plugin.
Edit the **peridot.php**, write the code to register.

```
use holyshared\peridot\temporary\TemporaryPlugin;

return function(EventEmitterInterface $emitter)
{
    TemporaryPlugin::create()->registerTo($emitter);
};
```

### Create a temporary directory

[](#create-a-temporary-directory)

Create a temporary directory, call the **makeDirectory** method.
Directory name is generated by [UUID](http://tools.ietf.org/html/rfc4122.html), use the id.

Permissions can be specified in the argument.

```
beforeEach(function() {
    $this->temp = $this->makeDirectory(); //return holyshared\peridot\temporary\TemporaryDirectory instance
});
it('create temporary directory', function() {
    expect($this->temp->exists())->toBeTrue();
});
```

or

```
beforeEach(function() {
    $this->temp = $this->makeDirectory(0755);
});
it('create temporary directory', function() {
    expect($this->temp->exists())->toBeTrue();
});
```

### Create a temporary file

[](#create-a-temporary-file)

Create a temporary file, call the **makeFile** method.
File name is generated by [UUID](http://tools.ietf.org/html/rfc4122.html), use the id.

Permissions can be specified in the argument.

```
beforeEach(function() {
    $this->temp = $this->makeFile(); //return holyshared\peridot\temporary\TemporaryFile instance
});
it('create temporary file', function() {
    expect($this->temp->exists())->toBeTrue();
});
```

or

```
beforeEach(function() {
    $this->temp = $this->makeFile(0755);
});
it('create temporary file', function() {
    expect($this->temp->exists())->toBeTrue();
});
```

Write to a temporary file
-------------------------

[](#write-to-a-temporary-file)

You can output the data to a temporary file in the **write** or **writeln** method of TemporaryFile instance.

```
beforeEach(function() {
    $this->tempDirectory = $this->makeDirectory();
    $this->tempFile = $this->tempDirectory->createNewFile('report.txt');

    $this->tempFile->writeln('Hello world!!');
    $this->tempFile->writeln('Hello world!!');
});
afterEach(function() {
    $this->cleanUpTemporary();
});
```

or

```
beforeEach(function() {
    $tempDirectory = $this->makeDirectory();
    $tempFilePath = $tempDirectory->resolvePath('report.txt'); //File not created!!

    $tempFile = new SplFileObject($tempFilePath, 'w');
    $tempFile->fwrite('Hello world!!');
    $tempFile->fwrite('Hello world!!');
    $tempFile = null;
});
```

Running tests
-------------

[](#running-tests)

Run with the following command.

```
composer test

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

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

Recently: every ~56 days

Total

18

Last Release

3792d ago

Major Versions

0.4.3 → 1.0.02015-05-01

PHP version history (2 changes)0.1.0PHP &gt;=5.4.0

1.0.0PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/70c299d6d6015ee714954aa05e4d0e9c7b1d31318a5d7db5e9bb4e1f70f78afc?d=identicon)[holyshared](/maintainers/holyshared)

---

Top Contributors

[![holyshared](https://avatars.githubusercontent.com/u/167190?v=4)](https://github.com/holyshared "holyshared (99 commits)")

---

Tags

plugintesttemporary-directorytemporaryperidottemporary file

### Embed Badge

![Health badge](/badges/holyshared-peridot-temporary-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/holyshared-peridot-temporary-plugin/health.svg)](https://phpackages.com/packages/holyshared-peridot-temporary-plugin)
```

###  Alternatives

[mockery/mockery

Mockery is a simple yet flexible PHP mock object framework

10.7k497.0M23.6k](/packages/mockery-mockery)[hamcrest/hamcrest-php

This is the PHP port of Hamcrest Matchers

7.0k484.1M109](/packages/hamcrest-hamcrest-php)[nelmio/alice

Expressive fixtures generator

2.5k43.4M133](/packages/nelmio-alice)[spatie/temporary-directory

Easily create, use and destroy temporary directories

96889.9M206](/packages/spatie-temporary-directory)[dealerdirect/phpcodesniffer-composer-installer

PHP\_CodeSniffer Standards Composer Installer Plugin

598161.9M1.9k](/packages/dealerdirect-phpcodesniffer-composer-installer)[zenstruck/foundry

A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.

78611.9M97](/packages/zenstruck-foundry)

PHPackages © 2026

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