Download the PHP package spiral-packages/symfony-serializer without Composer

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

Symfony serializer bridge for Spiral Framework

PHP Version Require Latest Stable Version phpunit psalm Total Downloads

This package provides an extension to the default list of serializers in Spiral Framework, allowing you to easily serialize and deserialize objects into various formats such as JSON, XML, CSV, and YAML.

Note Read more about spiral/serializer component in the official documentation.

If you are building a REST API or working with queues, this package will be especially useful as it allows you to use objects as payload instead of simple arrays.

This documentation will guide you through the installation process and provide examples of how to use the package to serialize and deserialize your objects.

Requirements

Make sure that your server is configured with following PHP version and extensions:

Installation

You can install the package via composer:

After package install you need to register bootloader from the package.

Note Bootloader Spiral\Serializer\Bootloader\SerializerBootloader can be removed. If you are using spiral-packages/discoverer, you don't need to register bootloader by yourself.

Configuration

The package comes with default configurations for normalizers, encoders, and metadataLoader. However, you can change these configurations based on your project's requirements.

There are two ways to configure the package:

Config file

You can create a configuration file app/config/symfony-serializer.php and define normalizers, encoders, and Symfony\Component\Serializer\Mapping\Loader\LoaderInterface for Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory used by the Symfony Serializer component parameters to extend the default configuration.

Here is an example of the configuration file:

Bootloader

Spiral\Serializer\Symfony\EncodersRegistryInterface and Spiral\Serializer\Symfony\NormalizersRegistryInterface provided by the package to add your own normalizers or encoders. You can register your own normalizers or encoders using the register method provided by these interfaces.

Here is an example:

Usage

The package provides a list of serializers that can be used to serialize and deserialize objects.

The serializers available in this package are: symfony-json, symfony-csv, symfony-xml, symfony-yaml.

Warning The yaml encoder requires the symfony/yaml package and is disabled when the package is not installed. Install the symfony/yaml package and the encoder will be automatically enabled.

Here are several ways to use these serializers:

1. Set a default serializer

You can set a desired Symfony serializer as the default application serializer by setting the DEFAULT_SERIALIZER_FORMAT environment variable.

Once the default serializer is set, you can request the Spiral\Serializer\SerializerInterface from the container and use it to serialize and deserialize objects.

Serialization:

Deserialization:

2. Using with the Serializer Manager

You can request a desired serializer from Spiral\Serializer\SerializerManager by its name. Once you have the serializer, you can use it to serialize and deserialize objects.

Serialization:

Deserialization:

Alternatively, you can use the serialize and unserialize methods of the manager class:

3. Using with Symfony Serializer

You can also use the Symfony Serializer directly by requesting the Symfony\Component\Serializer\SerializerInterface from the container. Once you have the serializer, you can use it to serialize and deserialize objects.

Here's an example:

Additional methods

Symfony Serializer Manager provides additional methods to work with data:

These methods provide additional flexibility for working with different data formats and can be useful in certain scenarios.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.


All versions of symfony-serializer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
spiral/boot Version ^3.7
spiral/core Version ^3.7
spiral/config Version ^3.7
doctrine/annotations Version ^1.12 || ^2.0
spiral/serializer Version ^3.7
symfony/property-info Version ^6.4 || ^7.0
symfony/serializer Version ^6.4 || ^7.0
symfony/property-access Version ^6.4 || ^7.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 spiral-packages/symfony-serializer contains the following files

Loading the files please wait ....