{"id":13601095,"url":"https://github.com/biberlabs/ddd-embeddables","last_synced_at":"2026-03-17T22:11:58.186Z","repository":{"id":61223901,"uuid":"68447110","full_name":"biberlabs/ddd-embeddables","owner":"biberlabs","description":"A collection of reusable value objects written in PHP and targeting version 8.0 and above.","archived":false,"fork":false,"pushed_at":"2022-10-10T21:20:04.000Z","size":101,"stargazers_count":66,"open_issues_count":3,"forks_count":10,"subscribers_count":7,"default_branch":"develop","last_synced_at":"2025-12-14T21:55:36.636Z","etag":null,"topics":["ddd-embeddables","doctrine-orm","domain-driven-design","embeddable","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/biberlabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-17T11:01:28.000Z","updated_at":"2025-10-13T09:42:51.000Z","dependencies_parsed_at":"2022-10-13T01:49:00.077Z","dependency_job_id":null,"html_url":"https://github.com/biberlabs/ddd-embeddables","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/biberlabs/ddd-embeddables","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biberlabs%2Fddd-embeddables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biberlabs%2Fddd-embeddables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biberlabs%2Fddd-embeddables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biberlabs%2Fddd-embeddables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biberlabs","download_url":"https://codeload.github.com/biberlabs/ddd-embeddables/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biberlabs%2Fddd-embeddables/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30633241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ddd-embeddables","doctrine-orm","domain-driven-design","embeddable","php"],"created_at":"2024-08-01T18:00:55.621Z","updated_at":"2026-03-17T22:11:58.158Z","avatar_url":"https://github.com/biberlabs.png","language":"PHP","readme":"# DDD Embeddables\n\n----\n\n[![Build Status](https://secure.travis-ci.org/biberlabs/ddd-embeddables.svg?branch=master)](https://secure.travis-ci.org/biberlabs/ddd-embeddables)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/biberlabs/ddd-embeddables/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/biberlabs/ddd-embeddables/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/biberlabs/ddd-embeddables/badges/coverage.png?b=master\u0026rand=123)](https://scrutinizer-ci.com/g/biberlabs/ddd-embeddables/?branch=master)\n\nA collection of reusable value objects written in PHP and targeting versions 8.0 and above. Value objects are essential building blocks of **Domain Driven Design** approach and described by Martin Fowler in _P of EAA page 486_ as below:\n\n\u003e \"Value object is a small simple object, like money or a date range, whose equality isn't based on identity.\"\n\n\u003e \u0026ndash; Martin Fowler\n\nAll classes in this library annotated as `ORM\\Embeddable` with appropriately adjusted column attributes. This makes them ready to use in any project with Doctrine ORM as [Embeddables](http://doctrine-orm.readthedocs.io/projects/doctrine-orm/en/latest/tutorials/embeddables.html).\n\n## Installation \u0026 Usage\nInstall the library using [composer](https://getcomposer.org).\n\n```bash\n$ composer require biberlabs/ddd-embeddables\n```\n\nand use it in your entities:\n\n```php\n\u003c?php\n\nnamespace MyApp\\Entity;\n\nuse Doctrine\\ORM\\Mapping as ORM;\nuse DDD\\Embeddable\\EmailAddress;\n\n/**\n * @ORM\\Entity\n */\nclass User {\n\n    /**\n     * @ORM\\Embedded(class=\"DDD\\Embeddable\\EmailAddress\")\n     */\n    private $email;\n\n    // Returns an EmailAddress instance, not a string\n    public function getEmail();\n\n    // Use type-hinting if you need a setter\n    public function setEmail(EmailAddress $email);\n}\n```\n\nAfterwards, you can write custom [DQL queries](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/dql-doctrine-query-language.html) based on your requirements while accessing properties of the value objects such as:\n\n```sql\nSELECT u FROM User u WHERE u.email = :email\n-- OR\nSELECT p FROM Payments p WHERE p.total.currency = :currency\nSELECT p FROM Payments p WHERE p.total.amount \u003e 1000\n-- OR\nSELECT u FROM User u WHERE u.name.surname = :surname\nSELECT u FROM User u WHERE u.name.title = :title\n```\n\nValue objects enables us to write much more cleaner and readable rules when dealing with the domain rules, application-wide. For example:\n\n```php\n$username  = $user-\u003egetEmail()-\u003egetLocalpart();\n```\n\nor\n\n```php\n$blacklist = ['spam4me.io', 'foo.com'];\nif(in_array($user-\u003egetEmail()-\u003egetDomain(), $blacklist)) {\n   // ...\n}\n```\n\neven \n\n```php\nif($company-\u003ehasMap()) {\n    $latLng = $company-\u003egetAddress()-\u003egetGeoPoint()-\u003etoArray();\n    //..\n}\n\nclass Company\n{\n    // ...\n       \n    /**\n     * Returns a boolean TRUE if the geolocation of the company is known,\n     * FALSE otherwise.\n     *\n     * @return bool\n     */\n    public function hasMap()\n    {\n        return $this-\u003egetAddress()-\u003egetGeoPoint() !== null;\n    }\n}\n```\n   \n## Running Tests\nYou can run unit tests locally via issuing the command below:\n\n```bash\n$ composer test\n```\n\nPlease make sure that all test are green before creating a PR.\n\n```\nPHPUnit 9.5.25 #StandWithUkraine\n\n................................................................. 65 / 75 ( 86%)\n..........                                                        75 / 75 (100%)\n\nTime: 00:00.037, Memory: 6.00 MB\n\nOK (75 tests, 124 assertions)\n```\n\n## Contributing\nIf you want to contribute to **ddd-embeddables** and make it better, your help is very welcome.\n\nPlease take a look our [CONTRIBUTING.md](CONTRIBUTING.md) before creating a pull request.\n\n## Further Reading\nAre you interested in Domain Driven Design? Here is a list of good resources to dig in-depth.\n\n - [Value Objects](http://martinfowler.com/bliki/ValueObject.html) - Martin Fowler\n - [Separating Concerns using Embeddables](http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/embeddables.html) - Doctrine ORM documentation\n - [Domain-Driven Design in PHP](https://leanpub.com/ddd-in-php/read) - Leanpub 380 pages e-book.\n - [Agregate Componenet Pattern In Action](https://lostechies.com/jimmybogard/2009/02/05/ddd-aggregate-component-pattern-in-action/) - Another good article from 2009\n - [Domain Driven Design Concepts in ZF2](https://olegkrivtcov.wordpress.com/2014/03/22/domain-driven-design-ddd-concepts-in-zf2/) - An article written by Oleg Krivtsov in 2014\n - [Domain Driven Design Quickly](https://www.infoq.com/minibooks/domain-driven-design-quickly) - A quickly-readable minibook and introduction to the fundamentals of DDD by InfoQ.\n","funding_links":[],"categories":["Repositories","Related Projects"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiberlabs%2Fddd-embeddables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiberlabs%2Fddd-embeddables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiberlabs%2Fddd-embeddables/lists"}