Download the PHP package bluem/javascript-serializer without Composer

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

Build Status SensioLabsInsight

Overview

This library provides a simple, dependency-free serialization of a PHP variable value / datastructure to strings which can be interpreted as a JavaScript value.

The most typical use case will be the automated generation of JavaScript code in cases where the amount of data is notably and therefore serializing to JSON would suffer from the deserialization penalty and/or the larger size of JSON data.

While I would have expected there are already some simililar libraries on packagist.org, I did not find any that are not bound to a specific use case, dataset or framework. If I missed something, please do not hesitate to contact me.

Installation

Add "bluem/javascript-serializer": "^1.0" to the requirements in your composer.json file or run composer require "bluem/javascript-serializer" at the shell.

As this library uses semantic versioning, you will get fixes and feature additions when running composer update, but not changes which break the API.

Usage

Instantiate the class, call the serialize() method with any variable and use the return type. That’s it.

$jss = new \BlueM\JavaScriptSerializer();
$result = $jss->serialize($myVariable);

The following datatypes can be handled:

Examples

Example 1: Scalar PHP value

Input PHP data:

$var = 'Hello world';

Value returned from $serializer->serialize($var) call will be this string:

'Hello world'

Example 2: Array with numeric keys

Input PHP data:

$var = ['A', 'B', 3.14, 4711];

Value returned from $serializer->serialize($var) call will be this string:

['A', 'B', 3.14, 4711]

Example 3: Nested array

Input PHP data:

[
    'foo'    => 'bar',
    'nested' => [
        'pi'     => 3.14,
        'key'    => null,
        'abc'    => "String \" with 'quotes'",
        'My key' => 'Hello world',
        'bar'    => [
            'key'  => 'A',
            'code' => 65,
        ],
    ]
]

Value returned from $serializer->serialize($var) call will be this string:

{foo: 'bar', nested: {pi: 3.14, key: null, abc: 'String " with \'quotes\'', 'My key': 'Hello world', bar: {key: 'A', code: 65}}}

Known issues

ToDo

Version History

1.1, 2019-03-28

1.0.1, 2017-10-14

1.0, 2017-05-04

Author & License

This code was written by Carsten Blüm (www.bluem.net) and licensed under the BSD 2-Clause license.


All versions of javascript-serializer with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.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 bluem/javascript-serializer contains the following files

Loading the files please wait ....