Download the PHP package earc/serializer without Composer

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

earc/serializer

Standalone lightweight extendable serializer component of the eArc libraries.

Although it's a small library, it is very powerful. With just a few lines of code you can use it to import entities from csv or map them to a bunch of sql-tables.

table of contents

installation

Install the earc serializer library via composer.

basic usage

First enable the earc/di dependency injection component.

Now your ready to serialize some content.

$value is the same as $deserializedValue.

The data types DateTime, object, array, string, int,float, bool and null values are supported by the default serialization type out of the box.

Even serialization of recursive object structures are possible.

This outputs:

{"type":"X","value":{"content":{"referenceToY":{"type":"Y","value":{"content":{"referenceToX":{"type":"X","value":{"content":null,"id":57}}},"id":60}}},"id":57}}

$object yields an instance of X referencing an instance of Y having a reference on X. Of course, it is not the same instance as serialized. It's an identical instance like you would receive on cloning the object. If multiple references point to the same instance, this holds also true after deserialization. You can enforce same instances by wrapping multiple objects into an array.

The deserialized value would also hold two references to the same instance of the class Z1.

advanced usage

The basic usage of the earc/serializer is not superior to the native php serialize/unserialize function. You should use the earc/serializer only if you need the advanced features.

filtering properties

The earc/serializer offers an easy way to organize the filtering of properties. Extend the SerializerDefaultType and overwrite the filterProperty() method. Only if this method returns true the property will be serialized.

To use this Filter use an object of the extending class as second argument.

customizing serialization via specialized data types

There are use cases where you need full control over the serialization process. For example in the case of further processing the serialized value or if your object/data needs a special processing prior serialization or post deserialization. Specialized data types offer you this level of control while keeping your architecture clean.

To create your own data type implement the DataTypeInterface.

Hint 1: serialize() can return anything that can be processed by the native php function json_encode(). If it is not an array or does not have the type and value keys the $type parameter will be an empty string and the $value parameter will hold the serialized value.

Hint 2: You can use the FactoryService, SerializeService or the ObjectHashService for specialized tasks.

To use the new data type you need a serializer type referencing the new data type. Either implement the SerializerTypeInterface or extend the SerializerDefaultType and overwrite the getDataTypes() method.

Note the order. If multiple data types are applicable, the data type placed first is applied.

Hint: If you need to build the MyDataType object by another dependency injection system than earc/di you can pass the object instead of null.

To use the new serializer type instead of the default pass its object as second argument to the serializer methods.

Hint: You can use your own dependency injection function (or container) to build the serializer type object.

data mapping

You can use earc/serializer to do all kinds of data mapping, even if tables are involved. This includes mapping (nested) objects to csv or sql and back. Check the examples' folder to get an impression.

releases

release v1.1

release v1.0

release v0.1

release v0.0

first official release


All versions of serializer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0 || ^7.4
earc/di Version ^3.0 || ^2.4
ext-json 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 earc/serializer contains the following files

Loading the files please wait ....