mapado/pretty-types
最新稳定版本:v1.1.0
Composer 安装命令:
composer require mapado/pretty-types
包简介
Doctrine Type storing pretty printed JSON into database
关键字:
README 文档
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 datetime_immutable: Mapado\PrettyTypes\UTCDateTimeImmutableType 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 utc_datetime_immutable: Mapado\PrettyTypes\UTCDateTimeImmutableType
Usage
In your entities, if you overrode the default datetime types, Doctrine will implicitly use the new types for all datetime fields:
#[ORM\Column] private \DateTime $someDate; #[ORM\Column] private \DateTimeImmutable $someDate;
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(type: 'utcdatetime')] private \DateTime $someDate; #[ORM\Column(type: 'utc_datetime_immutable')] private \DateTimeImmutable $someDate;
License
This project is licensed under the MIT license.
统计信息
- 总下载量: 13.18k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-02-20