百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

consistence

> 数据库
开源

一致性 - PHP功能的一致方法和添加

182 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一致性 - PHP功能的一致方法和添加

Consistence

PHP offers a lot of handy functionality, but due to its organic growth this is not always easily usable. The aim of this library is to provide consistent approach to PHP's functionality. This means:

  • clear and consistent naming patterns
  • consistent arguments order
  • errors reported as Exceptions, never as return values
  • added functionality and interfaces, which are missing
  • value objects representing common elements

Installation

Install package consistence/consistence with Composer:

bash
composer require consistence/consistence

There are no further steps needed, you can start using Consistence whenever suitable in your codebase, see features below.

Integrations

If you are using one of the following libraries/frameworks, check out these integrations:

  • Doctrine ORM integration provides integration to store Consistence value objects in database through entities, there is also Symfony bundle with this integration
  • JMS Serializer integration provides integration to (de)serialize Consistence value objects, there is also Symfony bundle with this integration

Documentation & features

In following sections, there are excerpts of Consistence functionality helping in key areas along with links to dedicated documentation pages.

Enums and MultiEnums

Enums represent predefined set of values. The available values are defined statically by each enum class. Each value is represented by an instance of this class in a flyweight manner. This ensures that the same values are always the same instance.

php
 Learn more about Enums in Consistence](docs/Enum/enums.md)

With [MultiEnums](docs/Enum/multi-enums.md) you can even represent multiple values and operations on them in a single object.

### [Strict Types](docs/Type/strict-types.md)

PHP contains by default a lot of magic behavior and checks almost nothing. When particular type is expected, PHP tries to convert given type to the expected one, which can yield unexpected results. Consistence promotes using strict types to achieve more predictable, maintainable and readable code.

```php
bar = 'bar';
php
 Learn more about Strict Types in Consistence](docs/Type/strict-types.md)

### [Time Format](docs/Time/time-format.md)

Using [value objects](http://martinfowler.com/bliki/ValueObject.html) is great, because you get clear type hint and you can be sure, that the value you get is in consistent state and that it is valid (if the representation follows the principles).

[DateTime](http://php.net/manual/en/class.datetime.php) is one of the few value objects which are natively in PHP. Unfortunately, PHP again prefers using magic behavior over clear errors by default and there is also quite a lot of commonly required functionality missing, so Consistence tries to help with these shortcomings.

…

php
 Learn more about Arrays in Consistence](docs/Type/arrays.md)

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPconsistenceenumphpstrict-types

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库