A PHP library that formats bytes into a human-readable format and vice versa.
Report a Bug
·
New Pull Request
This library provides functionality to convert bytes into a human-readable format and vice versa. It allows customization of formatting options and supports error handling for invalid inputs.
You can install this library via Composer. Run the following command:
composer require ramazancetinkaya/byte-formatter
<?php
require 'vendor/autoload.php'; // Composer autoload file
use ramazancetinkaya\ByteFormatter;
// Create an instance of ByteFormatter
$formatter = new ByteFormatter();
// Format bytes
echo $formatter->format(2048); // Output: 2 KB
// Convert from human-readable size to bytes
echo $formatter->convertToBytes('2 KB'); // Output: 2048
Contributions are welcome! Please fork the repository and create a pull request.
This project is licensed under the MIT License. For more details, see the LICENSE file.