Download the PHP package benmorel/weakmap-polyfill without Composer

On this page you can find all versions of the php package benmorel/weakmap-polyfill. 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 weakmap-polyfill

WeakMap polyfill for PHP 7.4

This polyfill aims to be 100% compatible with WeakMap in PHP 8.

Build Status Coverage Status Latest Stable Version Total Downloads License

Introduction

PHP 7.4 introduced WeakReference, but didn't include a WeakMap implementation. This has been implemented since, but is only available in PHP 8.

The RFC author, Nikita Popov, highlights why a userland WeakMap is suboptimal:

Weak maps require first-class language support and cannot be implemented using existing functionality provided by PHP.

At first sight, it may seem that an array mapping from spl_object_id() to arbitrary values could serve the purpose of a weak map. This is not the case for multiple reasons:

  • spl_object_id() values are reused after the object is destroyed. Two different objects can have the same object ID – just not at the same time.
  • The object ID cannot be converted back into an object, so iteration over the map is not possible.
  • The value stored under the ID will not be released when the object is destroyed.

Using the WeakReference class introduced in PHP 7.4, it is possible to avoid the first two issues (…). However, this does not solve the third problem: The data will not be released when the object is destroyed. It will only be released on the next access with an object that has the same reused ID, or if a garbage collection mechanism, which performs regular sweeps of the whole map, is implemented.

A native weak map implementation will instead remove the value from the weak map as soon as the object key is destroyed.

This is the trade-off this library offers: a 100% compatible implementation, but:

Here is how it works:

This offers a reasonable trade-off between performance and memory usage.

Installation

This library is installable via Composer:

Requirements

This library requires PHP 7.4 or later.

Quickstart

Alternatives

The weakreference_bc PECL backports a native polyfill for WeakReference and WeakMap to PHP 7.0-7.4. The PECL has the following advantages:

This has the following drawbacks:


All versions of weakmap-polyfill with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
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 benmorel/weakmap-polyfill contains the following files

Loading the files please wait ....