PHP Classes

PHP File Size to Human Readable: Calculate the size of files and directories

Recommend this page to a friend!
  Info   View files Documentation   View files View files (21)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 70 All time: 10,256 This week: 488Up
Version License PHP version Categories
objectsize 1.0MIT/X Consortium ...7.1PHP 5, Files and Folders, Text proces...
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.

Picture of Rafal Janisz
Name: Rafal Janisz <contact>
Classes: 3 packages by
Country: Poland Poland
Age: 36
All time rank: 415796 in Poland Poland
Week rank: 93 Up3 in Poland Poland Up

Documentation

objectsize

Build Status codecov

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">

alt Buy me a coffee

</a>

License

objectsize is licensed under the MIT License - see the LICENSE file for details


  Files folder image Files  
File Role Description
Files folder imagedocs (1 directory)
Files folder imagesrc (1 directory)
Files folder imagetests (1 directory)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file clover.xml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  docs  
File Role Description
Files folder imageassets (1 file)

  Files folder image Files  /  docs  /  assets  
File Role Description
  Accessible without login Image file bmc.png Icon Icon image

  Files folder image Files  /  src  
File Role Description
Files folder imageObjectSize (6 files)

  Files folder image Files  /  src  /  ObjectSize  
File Role Description
  Plain text file DirectorySize.php Class Class source
  Plain text file FileSize.php Class Class source
  Plain text file ObjectBase.php Class Class source
  Plain text file ObjectSize.php Class Class source
  Plain text file ObjectSizeException.php Class Class source
  Plain text file Size.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageObjectSize (3 files, 1 directory)

  Files folder image Files  /  tests  /  ObjectSize  
File Role Description
Files folder imageassets (1 file, 2 directories)
  Plain text file DirectorySizeTest.php Class Class source
  Plain text file FileSizeTest.php Class Class source
  Plain text file ObjectSizeTest.php Class Class source

  Files folder image Files  /  tests  /  ObjectSize  /  assets  
File Role Description
Files folder imagedir (2 files)
Files folder imagelink (2 files)
  Accessible without login Plain text file test.txt Doc. Documentation

  Files folder image Files  /  tests  /  ObjectSize  /  assets  /  dir  
File Role Description
  Accessible without login Plain text file test.txt Doc. Documentation
  Accessible without login Plain text file test2.txt Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:70
This week:0
All time:10,256
This week:488Up