Download the PHP package awesome/simdjson_plus without Composer

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

awesome/simdjson_plus

Tests status Latest Stable Version

🚀 Blazing-fast JSON encoding and decoding for PHP, powered by the simdjson project.

This is a fork of JakubOnderka/simdjson_php (which is a fork of crazyxman/simdjson_php)

Since the simdjson PECL extension seems to be unmaintained, or at least slow to accept PRs for improvements, we packaged this up under a new name (simdjson_plus) to avoid naming conflicts and published it on Packagist (instead of PECL) for easier installation.

It's a drop-in replacement for the PECL extension, with additional features from JakubOnderka, such as accelerated JSON encoding (not just decoding) and optimizations.

Performance Comparison: How Fast is simdjson_plus?

Operation PHP Built-in simdjson_plus Speedup
Decode to array 1.48 ms 0.46 ms 3.2×
Decode to object 1.56 ms 0.54 ms 2.9×
Encode 0.67 ms 0.26 ms 2.5×
Encode (pretty print) 0.83 ms 0.31 ms 2.6×
Validate 1.37 ms 0.22 ms 6.2×
Count items 1.51 ms 0.16 ms 9.4×

Tests were conducted using PHP 8.3 on an Apple M1 Max. For test specification see TwitterDecodeBench.php and TwitterEncoderBench.php.

Additionally, simdjson_plus reduces memory usage compared to json_decode(). For example, when decoding twitter.json, memory consumption drops from 3.01 MB to 2.47 MB due to efficient array key deduplication.

Related SIMD-accelerated PHP extensions

Requirements

Changes

See the change log.

Installing

Use Composer to install this library using PIE:

Compilation Instructions for Linux

To compile simdjson_plus, run the following commands:

Once installed, add this line to your php.ini file:

Usage Examples

Encoder

Most of available options of default json_encode() method are not supported by simdjson_encode() as they are usually useless.

simdjson_encode($value) method has similar behaviour as json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR)

Supported options are:

Differences are:

Base64 encoding

JSON format do not support binary data. Common way how to transfer binary data in JSON encoding is using base64 encoding. If you need to include base64 encoded value into JSON, you can use SimdJsonBase64Encode class that offers optimised converting to base64 value into JSON and use less memory. As creating new object in PHP is relatively slow, this approach make sense for string longer than 1 kB.

You can also use base64url encoding (RFC 4648 §5) by setting second argument to true: new SimdJsonBase64Encode($fileContent, true);

Encode to stream

For large data sets, simdjson_plus provides the simdjson_encode_to_stream() function to save data directly to a file or output buffer.

Decoder

There are some differences from json_decode() due to the implementation of the underlying simdjson library. This will throw a SimdJsonDecoderException if simdjson rejects the JSON.

Note that the simdjson PECL is using a fork of the simdjson C library to imitate php's handling of integers and floats in JSON.

1) The maximum string length that can be passed to simdjson_decode() is 4GiB (4294967295 bytes). json_decode() can decode longer strings.

2) The handling of max depth is counted slightly differently for empty vs non-empty objects/arrays. In json_decode, an array with a scalar has the same depth as an array with no elements. In simdjson_decode, an array with a scalar is one level deeper than an array with no elements. For typical use cases, this shouldn't matter. (e.g. simdjson_decode('[[]]', true, 2) will succeed but json_decode('[[]]', true, 2) and simdjson_decode('[[1]]', true, 2) will fail.)

Decode from stream

If you need to decode a big file from JSON format that you want to save to a file or send to a user, you can use the simdjson_decode_from_stream method.

Benchmarks

See the benchmark folder for more benchmarks.


All versions of simdjson_plus with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
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 awesome/simdjson_plus contains the following files

Loading the files please wait ...