Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

consistence

> 数据库
Open source

Consistence - consistent approach and additions to PHP's functionality

182 stars0 likes1 views
WebsiteGitHub

About

Consistence - consistent approach and additions to PHP's functionality

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 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPconsistenceenumphpstrict-types

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category数据库
PricingOpen source

> Related tools

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