v0.1.3 2022-04-25 19:10 UTC

This package is auto-updated.

Last update: 2024-10-26 00:24:12 UTC


README

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