Download the PHP package thiagocordeiro/serializer without Composer

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

PHP Serializer

This package allows you to parse json objects into php classes without the overhead of annotations, it checks for php object constructor and creates cache classes to convert json into a given class.

How to use

For Symfony projects a bundle is available at serializer-bundle

For Laravel projects a package is available at laravel-serializer

otherwise the package is available on composer:

PHP Serializer does not use setters, so your class must have a constructor with all properties coming from the json.

Basic example (Using getters)

Basic example (Using readonly properties)

Once you have your class, you can convert json string to it, ex.

The opposite way, ex.


Complex object construction - Objects

Constructors can also have arrays and other classes on it , the other class must follow same rules, for ex.

for this example a json string could contain or not address property:

or

Complex object construction - Arrays

Arrays are also welcome, but since there is no way to determine on the array type on object constructor, arrays require you to write php annotation, a simple doc bloc is everything it needs to deserialize any json string, ex

A json for this class would be:


Default values

By default all non-provided values will be filled with null, if the property is not nullable then you a TypeError will be thrown, but a property can also have a default value and in case it is not given, the default value will be used, ex.

A json without type would result an object with $type = 'user'. Note: Default value will only be used in case it is not provided, if it is provided as null then null will be the value.

Constructor with arguments

Constructor with DateTime/DateTimeImmutable

Contributing

Feel free to open issues or submit PRs

Supporting

If you feel like supporting changes then you can send donations to the address below.

Bitcoin Address: bc1qfyudlcxqnvqzxxgpvsfmadwudg4znk2z3asj9h


All versions of serializer with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
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 thiagocordeiro/serializer contains the following files

Loading the files please wait ....