Skip to content

msgframework/File

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The File library

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

About

This library provides utilities for the file.

Usage

Create file

...
use Msgframework\Lib\File\File;

$file = new File($path);

Get file extension

...
$file = new File($path);
$allow_extensions = array('jpg', 'png');

if (!in_array($extension = $file->getExtension(), $allow_extensions)) {
    throw new \RuntimeException(sprintf('File extension "%s" not allowed, allow: %s', $extension, implode(", ", $allow_extensions)));
}

Get file content

...
$file = new File($path);

$content = $file->getContent();

Installation

You can install this package easily with Composer.

Just require the package with the following command:

$ composer require msgframework/file