cars24/php-tmpfile

A convenience class for temporary files

1.1 2019-04-12 08:21 UTC

This package is not auto-updated.

Last update: 2024-04-21 07:02:14 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

A convenience class for temporary files.

Features

  • Create temporary file with arbitrary content
  • Delete file after use (can be disabled)
  • Send file to client, either inline or with save dialog
  • Save file locally

Examples

<?php
use mikehaertl\tmp\File;

$file = new File('some content', '.html');

// send to client for download
$file->send('home.html');

// save to disk
$file->saveAs('/dir/test.html');

// Access file name and directory
echo $file->getFileName();
echo $file->getTempDir();

If you want to keep the temporary file, e.g. for debugging, you can set the $delete property to false:

<?php
use mikehaertl\tmp\File;

$file = new File('some content', '.html');
$file->delete = false;