gubler/doctrine-extra-types

Adds extra and alternate Doctrine column types

v2.0.1 2021-06-17 12:16 UTC

This package is auto-updated.

Last update: 2024-04-17 18:11:42 UTC


README

This project provides extra or replacement data types for Doctrine 2.

Installation

The preferred method of installation is via Composer. Run the following command to install the package and add it as a requirement to your project's composer.json:

composer require gubler/doctrine-extra-types

Types

UTCDateTime

The UTCDateTimeType is copied from the [Doctrine ORM documentation][doctine-docs-utc] and converts DateTime object's timezone to UTC before storing them in the database.

Use

This replaces the existing Doctrine datetime type.

In Symfony:

# config/packages/doctrine.yaml
doctrine:
   dbal:
       types:
           datetime:
               class: Gubler\DoctrineExtraTypes\UTCDateTime\UTCDateTimeType

Note: This type only converts the DateTime when saving to the database. This does not convert the datetime back to the original timezone when reading form the database. You will need to convert the UTC datetime to whichever timezone you need.

After this, you can use the datetime Doctrine type normally and any DateTimes will be converted to UTC.

Guid

This project used to supply a GUID doctrine type. This is now provided by gubler/guid-doctrine

Contributing

Contributions are welcome! Please read CONTRIBUTING for details.

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.

Copyright and License

The gubler/doctrine-extra-types library is copyright © Daryl Gubler and licensed for use under the MIT License (MIT). Please see LICENSE for more information.