Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2019-10-21 (13 days ago) | | Not yet rated by the users | | Total: 2 This week: 2 | | All time: 9,758 This week: 184 |
|
Description | | Author |
This package can calculate the size of files and directories.
It takes the path of a file or a directory and returns the size in bytes of that file or the files contained in the given directory.
The package can return the total size as a number of bytes or a string that displays the number in a human readable format. | |
|
Details
objectsize
Converts file or directory to human readable number by taking the number of that unit that the bytes will go into it.
Requirements
- PHP >= 7.1
- ravjanisz/readablesize
- (optional) PHPUnit to run tests.
Install
Via Composer:
$ composer require ravjanisz/objectsize
Usage
//settings and object instance
use Rav\Size\SizeSettings;
use Rav\ObjectSize\ObjectSize;
//create settings for human readable size
$settings = new SizeSettings();
$settings->setPrecision(2);
//create object instance
$object = new ObjectSize($settings);
//set file/dir path
$object->setPath(__DIR__ . '/files/shark.jpeg');
//get value
echo $object->human();
//get value in bytes
echo $object->inBytes();
//set file/dir path
$object->setPath(__DIR__ . '/files');
//get value
echo $object->human();
//get value in bytes
echo $object->inBytes();
Documentation
None
Support the development
Do you like this project? Support it by donating
<a href="https://www.buymeacoffee.com/ravjanisz">
</a>
License
objectsize is licensed under the MIT License - see the LICENSE file for details
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.