Download the PHP package compositephp/entity without Composer
On this page you can find all versions of the php package compositephp/entity. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download compositephp/entity
More information about compositephp/entity
Files in compositephp/entity
Package entity
Short Description PHP 8.1+ Smart entity with hydration
License MIT
Informations about the package entity
Composite Entity
Composite Entity is a PHP 8.1+ lightweight class designed for efficient and intelligent data handling. It specializes in the serialization and deserialization of data, making it highly beneficial for database management.
Features
- Converts database rows to strictly typed objects and vice versa.
- Streamlines database interactions.
Overview:
- Requirements
- Installation
- Quick example
- Advanced usage
Requirements
- PHP 8.1 or higher.
Installation
Install using Composer::
Supported column types:
Composite Entity supports a wide range of data types:
- Basic types: String, Integer, Float, Bool, Array.
- Complex types: Object (stdClass), DateTime/DateTimeImmutable, Enum.
- Advanced types: Entity, Entity Lists or Maps, Collections (e.g., Doctrine Collection), Custom classes implementing Composite\DB\Entity\CastableInterface.
Quick example
Example of serialization:
You can also deserialize (hydrate) entity from array:
And that's it. No need for special getters or setters, no additional "behaviours" or extra layers of code. Composite Entity handles everything automatically, ensuring seamless data casting.
Advanced usage
Custom Hydration
For tailored performance, implement your own hydrator:
- Create a class implementing
Composite\Entity\HydratorInterface
. - Add
Composite\Entity\Attributes\Hydrator
attribute to your entity class.
Useful Attributes
-
Composite\Entity\Attributes\SkipSerialization
Exclude properties from hydration.
-
Composite\Entity\Attributes\ListOf
Define lists of entities within a property.
Example:
License:
MIT License (MIT). Please see LICENSE
for more information. Maintained by Composite PHP.