mapado/pretty-types

Doctrine Type storing pretty printed JSON into database

v0.1.0 2020-10-30 14:29 UTC

This package is auto-updated.

Last update: 2021-04-26 05:07:32 UTC


README

Installation

composer require  mapado/pretty-types

JSON pretty

Based on Doctrine DBAL types.

Will store pretty printed JSON into database.

Configuration

In your config file

# Doctrine Configuration
doctrine:
  dbal:
    types:
      json_pretty: Mapado\PrettyTypes\JsonPrettyType

Usage

In your entities

/**
 * ...
 *
 * @ORM\Column(name="column_name", type="json_pretty")
 */

UTCDateTime

If you want to store datetime in UTC in your database.

Copied version from Working with DateTime Instances.

All credits goes to the doctrine team !

Configuration

In your config file

# Doctrine Configuration
doctrine:
  dbal:
    types:
      datetime: Mapado\PrettyTypes\UTCDateTimeType
      datetimetz: Mapado\PrettyTypes\UTCDateTimeType

Be aware that this will override all datetimes configured with doctrine.

If you do not want to override everything and use a custom types instead:

# Doctrine Configuration
doctrine:
  dbal:
    types:
      utcdatetime: Mapado\PrettyTypes\UTCDateTimeType

Usage

In your entities

/**
 * ...
 *
 * @ORM\Column(name="column_name", type="datetime")
 */

You should store the timezone next to the datetime too. Read the doctrine documentation for more informations.

If you configured a custom type, use this instead:

/**
 * @ORM\Column(name="column_name", type="utcdatetime")
 */

License

This project is licensed under the MIT license.