Download the PHP package nassiry/filesize-handler without Composer

On this page you can find all versions of the php package nassiry/filesize-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filesize-handler

# PHP FileSizeHandler ![Packagist Downloads](https://img.shields.io/packagist/dt/nassiry/filesize-handler) ![Packagist Version](https://img.shields.io/packagist/v/nassiry/filesize-handler) ![PHP](https://img.shields.io/badge/PHP-%5E8.0-blue) ![License](https://img.shields.io/github/license/nassiry/filesize-handler)

The FileSizeHandler class is a utility designed to fetch and format file sizes across various file storage systems. It offers cross-platform compatibility with support for both SI (decimal) and IEC (binary) standards, making it HDD-agnostic and highly flexible.

This package addresses the discrepancies in file size measurement (binary vs decimal units) and provides flexible APIs for developers.

Features

  1. Supports Local, Remote, and FTP Files:
    • Easily calculate file sizes from multiple sources.
  2. Binary and Decimal Calculations:
    • Switch between binary (KiB, MiB, etc.) and decimal (KB, MB, etc.) bases with simple methods.
  3. Fluent Interface:
    • Intuitive method chaining for base selection and size formatting.
  4. Extensibility:
    • Ready for integration with cloud storage systems like S3 and Google Cloud.
  5. i18n Support:
    • Format file size with custom localized units.
    • Dynamically provide translations for units.
  6. Chaining and Echo Support:
    • Supports method chaining for cleaner code.
    • Directly echo the handler instance to get the formatted size.
  7. Custom Source Support:
    • Implement FileSourceInterface and register your custom source.

Table Of Contents

  1. Why Was This Class Created?
  2. Useful Links
  3. Requirements
  4. Installation
  5. Usage
    • Local File
    • Extending the Library
  6. Binary vs Decimal Units
    • Switching Units
    • Dynamic Locale and Unit Customization
  7. API Reference
    • Source Methods
    • Configuration Methods
    • Output Methods
  8. Extensions
    • Available Extensions
  9. Contributing
  10. License

Why Was This Class Created?

When working with file sizes, differences in measurement units across systems can cause confusion:

Useful Links

  1. Wikipedia: Binary Prefixes
    • Comprehensive explanation of binary (KiB, MiB) vs. decimal (KB, MB) prefixes.
  2. NIST: Prefixes for Binary Multiples
    • Official standards for binary-based units.
  3. IBM: Units of Measurement for Storage Data
    • Insights into storage measurement across platforms.
  4. Google: Byte Units
    • Guidelines for using decimal and binary units consistently.
  5. Metric View: What are binary prefixes?
    • Provides an overview of binary prefixes and their usage

Requirements

Installation

The recommended way use Composer to install the package:

Usage

Local File

By default, the library supports fetching file sizes for local files.

Extending the Library

To add support for a new file source, implement the FileSourceInterface:

For more information on extending the library, check the official extensions available.

Binary vs Decimal Units

Switching Units

Dynamic Locale and Unit Customization

Key Points:

Two-letter country codes are based on the ISO 3166-1 alpha-2 standard and are used in locale naming conventions.

API Reference

FileSizeHandler::create(string $locale = 'en_US', array $units = [])

Initializes a new FileSizeHandler instance.

Source Methods

Configuration Methods

Output Methods

Extensions

FileSizeHandler is extensible via optional extensions for advanced integrations. These extensions add support for remote and cloud-based file sources. Install the extensions via Composer.

Available Extensions:

Extension Description Installation Command Documentation
FTP Support for FTP file size retrieval. composer require nassiry/filesize-handler-ftp-extension See Full Documentation
Amazon S3 Fetch file sizes from Amazon S3 buckets. composer require nassiry/filesize-handler-s3-extension See Full Documentation
Google Cloud Retrieve file sizes from Google Cloud Storage. composer require nassiry/filesize-handler-googlecloud-extension See Full Documentation
Remote Support for files accessible via HTTP/HTTPS. composer require nassiry/filesize-handler-remote-extension See Full Documentation

Contributing

Feel free to submit issues or pull requests to improve the package. Contributions are welcome!

Changelog

See CHANGELOG for release details.

⚠️ Deprecated Methods

As of version 1.1.0, the following methods are deprecated and will be removed in version 2.0.0:

Deprecated Use Instead
baseBinary() binary()
baseDecimal() decimal()
formattedSize() format()
sizeInBytes() bytes()

License

This package is open-source software licensed under the MIT license.


All versions of filesize-handler with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-intl Version *
composer/installers Version ^1.12
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nassiry/filesize-handler contains the following files

Loading the files please wait ...