rosamarsky/jms-carbon-handler

Simple to use Carbon handler for the JMS Serializer

2.0 2018-10-12 22:48 UTC

This package is auto-updated.

Last update: 2024-10-27 09:35:24 UTC


README

Simple to use Carbon handler for JMS Serializer

Installation

composer require rosamarsky/jms-carbon-handler

Setup

Register the Carbon Handler via the builder object:

    $builder->configureHandlers(function (HandlerRegistry $registry) {
        $registry->registerSubscribingHandler(new CarbonHandler);
    });

Usage

As annotations:

    class SomeClass
    {
        /**
         * @Type("Carbon<'Y-m-d'>")
         */
        public $date;
    }

As YAML:

    date:
      type: Carbon<'d-m-Y'>

As XML:

    <property name="date" xml-attribute="true" type="Carbon"/>