Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.
/ TempFile Public archive

TempFile is a small library inspired by the SplTempFileObject providing solutions for commonly occurring problems when dealing with temporary files.

License

Notifications You must be signed in to change notification settings

arnegroskurth/TempFile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TempFile

Build Status codecov License

TempFile is a small library inspired by the SplTempFileObject providing solutions for commonly occurring tasks when dealing with temporary files.

Setup

$ composer require arne-groskurth/temp-file

Usage

<?php

use ArneGroskurth\TempFile\TempFile;

$tempFile = new TempFile();

// TempFile offers all commonly used file-related functions including fread, fwrite, ftell, fseek and feof.
$tempFile->fwrite('Hello World!');

// Construct response object and write to stdout
// (Requires installation of package "symfony/http-foundation")
$tempFile->send();

// Obtain path-based access to temporary file within callback function
$tempFile->accessPath(function($path) {
    
    $content = file_get_contents($path);
    
    $content = str_replace('Hello World!', 'Got you!', $content);
    
    file_put_contents($path, $content);
});

// Echos 'Got yout!'
print $tempFile->getContent();

// Persist temporary file to some path
$tempFile->persist('/my/path/filename.ext');

About

TempFile is a small library inspired by the SplTempFileObject providing solutions for commonly occurring problems when dealing with temporary files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages