Download the PHP package argo-php/serializer without Composer

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

argo-php/serializer

An object serializer (hydrator) for PHP.

It is necessary for serializing complex structured objects into string representations (JSON, XML, etc.) and for deserializing these objects from their string representations.

Its architecture is similar to the symfony/serializer package (some implementations are copied from there unchanged), so if you have any questions not answered in this documentation, you can refer to the original documentation at https://symfony.com/doc/current/serializer.html

Key differences from symfony/serializer:

Basic concepts

Normalizer / Denormalizer

A normalizer is a special class that can transform data of various types (including objects) into a unified representation (array or stdClass), which can then be easily represented as a string.

A denormalizer performs the reverse task of mapping an array/stdClass to specified types.

There are several ready-made normalizers:

Encoder / Decoder

An encoder converts a normalized object/array to a given format (JSON/XML/etc.). A decoder performs the opposite function: it converts a string in one of the formats into a normalized object/array.

This package contains only unified interfaces for working with encoders/decoders. The implementations for the required formats are provided in separate packages:

Context and ContextBag

A context is a special object that contains additional information for normalizers and encoders. A context allows you to control the normalization mechanism, such as changing field names, setting time and date formats, and indicating that a field in an object should not be serialized.

A ContextBag is a collection of objects with contexts. It allows you to retrieve the current context by the class name of that context.

A context can be set in advance when running serialization/deserialization/normalization/denormalization/encoding/decoding methods. A context can also be set using special attributes.

Attributes for setting context

DiscriminatorResolver and DiscriminatorEnricher

DiscriminatorResolver is a specialized class designed to resolve ambiguities during data denormalization. Possible ambiguities: a Union type, an abstract class, or an interface. This class resolves ambiguities in several ways:

  1. It checks whether the given field, or the abstract class that is the current field's type, has a Discriminator attribute, passed an instance of a custom DiscriminatorResolver implementing the DiscriminatorResolverInterface interface.
  2. It checks for the presence of the DiscriminatorMap attribute, which specifies the rules for resolving such situations (the name of the field to look at and an array of values ​​with the corresponding types to apply).
  3. It attempts to automatically select the most appropriate type from the Union type.

DiscriminatorEnricher is a class that performs the reverse operation: it augments normalized data with additional data that helps correctly interpret the various types represented in a given field.

In simple terms, it adds an additional field with a value that helps us understand what type the field was before normalization.

Its algorithm is similar to DiscriminatorResolver's: it first checks for the presence of the Discriminator attribute with a specified custom DiscriminatorEnricher implementing the DiscriminatorEnricherInterface interface, and then checks for the presence of the DiscriminatorMap attribute.

Serializer

This is the connection point for all previous entities. This means that serialization/deserialization processes occur through an instance of this class. Direct interaction with normalizers and encoders is not required, but preliminary configuration of the serializer based on your needs is required. An initialization example is provided in the "Usage Examples" section.

Contains the following methods:

There are also methods that allow you to perform not full serialization/deserialization, but only part of the stage:

Normalizes transmitted data

Encodes data into the required format from a normalized form

Decodes serialized data into a normalized form (object/array)

Denormalizes data from its normalized form to the specified type.

Normalization Groups

A special feature that allows you to specify in the context which group a particular class property (or the class itself) belongs to. Different context settings can then be applied to different groups, or certain fields can be ignored when serializing a specific group. The primary use case is to have different groups for serializing and deserializing data to the API (JSON) and to the database (for example, omitting certain fields from the DTO to the API but storing them in the database, or having different date formats).

Examples of use

Initializing the serializer:

Serialization and deserialization of an object


All versions of serializer with dependencies

PHP Build Version
Package Version
Requires php Version 8.3.*|8.4.*|8.5.*
argo-php/attribute-collector Version ^1.0
argo-php/entity-definition Version ^1.0
argo-php/types Version ^1.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 argo-php/serializer contains the following files

Loading the files please wait ...