Download the PHP package mrsuh/php-var-sizeof without Composer

On this page you can find all versions of the php package mrsuh/php-var-sizeof. 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 php-var-sizeof

PHP var_sizeof()

Tests

Function for getting size of any PHP variable in bytes.
It must be more accurate tool to calculate total size of PHP variable than memory_get_usage(), but it has restrictions.

How it works

var_sizeof() with var_class_sizeof() uses FFI to access internal structures of PHP variables.
It calculates the size of internal structures such as zval, _zend_array, _zend_object, etc., as well as additional allocated memory for them.
It doesn't take into calculate the memory of handlers/functions/etc.

Requirements

How to install

Functions

Usage

var_sizeof vs memory_get_usage

PHP 8.1.2 Linux(x86_64)

type var_sizeof(bytes) memory_get_usage(bytes)
NULL 16 0
boolean(true) 16 0
integer(1) 16 0
double(1.5) 16 0
string("hello world") 27 40
resource 48 416
callable 72 384
array(count: 0, list: true) 336 0
array(count: 100, list: true) 2,128 8,248
array(count: 1,000, list: true) 16,464 36,920
array(count: 10,000, list: true) 262,224 528,440
array(count: 100, list: false) 5,192 8,248
array(count: 1,000, list: false) 41,032 41,016
array(count: 10,000, list: false) 655,432 655,416
EmptyClass{} 72 40
ClassWithArray{"array(count: 0, list: true)"} 408 56
ClassWithArray{"array(count: 100, list: true)"} 2,200 8,304
ClassWithArray{"array(count: 1,000, list: true)"} 16,536 36,976
ClassWithArray{"array(count: 10,000, list: true)"} 262,296 528,496
ClassWithObject{"EmptyClass{}"} 144 96
ArrayIterator{"array(count: 100, list: true)"} 2,264 8,376
ArrayIterator{"array(count: 100, list: false)"} 5,328 40,376
type var_class_sizeof(bytes) var_sizeof(bytes) memory_get_usage(bytes)
EmptyClass{} 1,362 72 40
ClassWithArray{"array(count: 0, list: true)"} 1,494 408 56
ClassWithArray{"array(count: 100, list: true)"} 1,494 2,200 8,304
ClassWithArray{"array(count: 1,000, list: true)"} 1,494 16,536 36,976
ClassWithArray{"array(count: 10,000, list: true)"} 1,494 262,296 528,496
ClassWithObject{"EmptyClass{}"} 1,495 144 96
ArrayIterator{"array(count: 100, list: true)"} 2,437 2,264 8,376
ArrayIterator{"array(count: 100, list: false)"} 2,437 5,328 40,376

:warning: Restrictions

For contributors

How to reproduce a table of numbers above

How to compile library


All versions of php-var-sizeof with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-ffi Version *
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 mrsuh/php-var-sizeof contains the following files

Loading the files please wait ....