Download the PHP package mistralys/variable-hasher without Composer

On this page you can find all versions of the php package mistralys/variable-hasher. 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 variable-hasher

Variable hasher

PHP utility that can be used to create a hash of an arbitrary set of variables to use for runtime caching. It has better performance than serializing the variables and hashing the result, especially when objects and resources are involved.

Requirements

Installation

Use Composer to add the dependency to your project:

Quick start

Any kind of variable can be passed in, from primitives (int, float, string) to objects and resources, or arrays containing any of these - indexed or associative.

Real-life example

Consider a factory method that creates objects based on a set of parameters. The same instances must be returned if the same parameters are passed in again.

Order-independence

The order of the variables you pass in does not matter. The same hash will be generated regardless of the order if the variables are the same.

To illustrate, the following will generate the same hash:

Choosing the hash algorithm

By default, MD5 is used to generate the hash. If you need a different algorithm, you can specify any valid algorithm supported by PHP's hash() function.

In the example above, the algorithm is set using one of the provided constants. You can specify any valid algorithm as a string:

NOTE: The HashingAlgorithms class is provided for convenience. It contains constants for all algorithms that you can rely on being supported by PHP 8.4 without having to check hash_algos().

Get the raw hashing string

If you want to see the raw string that is hashed, you can set the algorithm to none, which will return the string instead of a hash.

Memory handling

The arguments are stored internally until you request the hash. This means that if you pass in large variables, they will remain in memory until the object is destroyed if you do not request it.

Warning: Runtime use only

The hashing uses object and resource IDs for performance reasons, which are not persistent between requests. As a result, the generated hashes cannot be used to identify a set of variables if it contains objects or resources.

If you need a persistent hash, you should use a different method, such as encoding the objects to JSON and generating a hash of this serialized data.


All versions of variable-hasher with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
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 mistralys/variable-hasher contains the following files

Loading the files please wait ...