You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pages/index.mdx
+26-27Lines changed: 26 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,59 +2,58 @@ import ExternalLink from "../components/external-link";
2
2
3
3
# Introduction
4
4
5
-
Unlock the full potential of Domain-Driven Design in your Laravel projects with the <ExternalLinkhref="https://github.com/wayofdev/laravel-cycle-orm-adapter">laravel-cycle-orm-adapter</ExternalLink> — the adapter package that seamlessly integrates the capabilities of <ExternalLinkhref="https://cycle-orm.dev">CycleORM</ExternalLink> — DataMapper ORM into <ExternalLinkhref="https://laravel.com">Laravel Framework</ExternalLink>.
5
+
Unlock the full potential of Domain-Driven Design in your Laravel projects with the <ExternalLinkhref="https://github.com/wayofdev/laravel-cycle-orm-adapter">laravel-cycle-orm-adapter</ExternalLink> — the adapter package that seamlessly integrates the capabilities of <ExternalLinkhref="https://cycle-orm.dev">CycleORM</ExternalLink> DataMapper ORM into <ExternalLinkhref="https://laravel.com">Laravel Framework</ExternalLink>.
6
6
7
7
This adapter bridges the gap between Laravel's rapid development capabilities and CycleORM's Data Mapper features, enabling you to craft complex, domain-centric applications, with separation of concerns, and a clear distinction between the domain model and the persistence layer.
8
8
9
9
## 🧐 Understanding the Limitations of Eloquent
10
10
11
-
While Eloquentis a powerful and convenient ORM for many projects, its Active Record implementation poses challenges for applications that require a clear separation between the domain logic (data model) and the infrastructure code (persistence). Ideally, the domain model should operate independently of the persistence layer, a principle that is central to DDD. This separation enhances testability, maintainability, and scalability, especially in complex applications or those developed by large teams with varying levels of expertise. Eloquent's approach, however, tends to blur these boundaries, leading to tightly coupled code that can hinder the enforcement of coding standards and complicate the application's evolution.
11
+
Eloquent, Laravel's default ORM, is a powerful and convenient tool for many projects, thanks to its simplicity and ActiveRecord implementation that streamlines database interactions. However, in applications that aim to implement Domain-Driven Design (DDD) principles, Eloquent's ActiveRecord pattern can pose some challenges, as your application grows in complexity
12
12
13
-
Eloquent is Laravel's shining star for ORM, beloved for its simplicity and ActiveRecord implementation that makes database interactions straightforward. However, its tight coupling between the domain models and the database layer can be a double-edged sword, especially in large-scale or complex applications. This coupling tends to mix the business logic with persistence concerns, making the codebase harder to maintain, test, and evolve. Moreover, Eloquent's approach can lead to bloated models, where business logic and database operations are intertwined, complicating the enforcement of clean architecture principles.
13
+
DDD emphasizes a clear separation between the domain logic (data model) and the infrastructure code (persistence), allowing the domain model to operate independently of the persistence layer. This separation is crucial for maintaining testability, maintainability, and scalability, especially in complex applications or those developed by large teams with varying levels of expertise.
14
14
15
+
Eloquent's ActiveRecord approach tends to blend the domain models and the database layer, leading to tightly coupled code. This coupling can make it difficult to enforce clean architecture principles, as the business logic and persistence concerns become intertwined. As a result, the codebase becomes harder to maintain, test, and evolve, particularly in large-scale or complex applications. Moreover, this approach can lead to bloated models, where business logic and database operations are mixed together, complicating the adherence to coding standards and the application's ability to adapt to change.
15
16
16
17
## 🤔 Why CycleORM in Laravel?
17
18
18
-
Laravel's Eloquent ORM is a fantastic tool for rapid development and common database interactions. However, as your application grows in complexity, Eloquent can encounter limitations when implementing strict Domain-Driven Design (DDD) patterns.
19
-
20
-
The Active Record pattern tightly couples domain logic and data persistence within the same model, potentially leading to challenges in maintaining a clean separation of concerns.
21
-
22
-
There were many attempts to bring DDD to Laravel:
19
+
Several notable attempts have been made to bring DDD to Laravel, such as:
23
20
24
21
* <ExternalLinkhref="https://laravel-beyond-crud.com">Laravel Beyond CRUD approach</ExternalLink> by Spatie
25
22
26
23
* <ExternalLinkhref="https://lorisleiva.com/conciliating-laravel-and-ddd">Conciliating Laravel and DDD</ExternalLink> by Loris Leiva
27
24
28
25
* <ExternalLinkhref="https://github.com/Orphail/laravel-ddd">Yet another Laravel 10 DDD interpretation</ExternalLink>
29
26
30
-
these often involve workarounds to adapt Eloquent rather than a fundamental shift in approach.
27
+
these often involve workarounds to adapt Eloquent rather than a fundamental shift in approach, by selecting a more suitable ORM for DDD.
31
28
32
-
The <ExternalLinkhref="https://github.com/wayofdev/laravel-cycle-orm-adapter">laravel-cycle-orm-adapter</ExternalLink> bridges this gap, by introducing DataMapper pattern capabilities to Laravel, empowering you to unlock the full potential of DDD within your projects.
29
+
The <ExternalLinkhref="https://github.com/wayofdev/laravel-cycle-orm-adapter">laravel-cycle-orm-adapter</ExternalLink> bridges this gap,
30
+
by introducing DataMapper pattern capabilities implemented by CycleORM, to Laravel, empowering you to unlock the full potential of DDD within your projects.
33
31
34
32
Here's why this combination shines:
35
33
36
-
* Separation of Concerns: The Data Mapper pattern enforced by CycleORM creates a clear boundary between your business logic (domain model) and data persistence mechanisms. This leads to a cleaner, more testable, and adaptable codebase.
37
-
38
-
* Tackling Complexity: As your project's business rules and data relationships become more intricate, CycleORM's features provide the flexibility to model and manage them effectively.
39
-
40
-
* Long-Term Maintainability: By decoupling your domain model from persistence details, your application becomes less brittle and easier to maintain as requirements evolve.
34
+
-**Domain-Driven Design:** This stack is designed to work with complex domain models, making it a perfect fit for DDD.
35
+
-**Separation of Concerns:** The Data Mapper pattern enforced by CycleORM creates a clear boundary between your business logic (domain model) and data persistence mechanisms. This leads to a cleaner, more testable, and adaptable codebase.
36
+
-**Tackling Complexity:** As your project's business rules and data relationships become more intricate, CycleORM's features provide the flexibility to model and manage them effectively.
37
+
-**Long-Term Maintainability:** By decoupling your domain model from persistence details, your application becomes less brittle and easier to maintain as requirements evolve.
41
38
39
+
## 🌟 Key Features
42
40
43
-
## 🚀 Features
44
-
45
-
### Laravel CycleORM Adapter Features
46
-
-**Seamless Integration**: The adapter is designed to work seamlessly with Laravel, allowing you to use CycleORM in your Laravel projects without any hassle.
47
-
-**Entity as Source of Truth for Database Migrations**: The adapter allows you to use your domain entities as the source of truth for your database schema, making it easier to keep your database schema in sync with your domain model.
48
-
-**Laravel Collections Support**: The adapter provides support for <ExternalLinkhref="https://laravel.com/docs/10.x/collections">Laravel Collections</ExternalLink>, allowing you to use them with your domain models and repositories
49
-
-**Database Factories**: Use Laravel database seeders together with CycleORM Entity Factories via <ExternalLinkhref="https://github.com/wayofdev/laravel-cycle-orm-factories">wayofdev/laravel-cycle-orm-factories</ExternalLink>
41
+
-**Seamless Integration**: The adapter is designed to work seamlessly with Laravel
42
+
-**Entity-Driven Database Migrations**: Unlike Eloquent ActiveRecord approach, where migrations stands as the source of truth, CycleORM allows you to use your domain entities as the source of truth for your database schema, making it easier to keep your database schema in sync with your domain model.
50
43
-**Real Repositories**: <ExternalLinkhref="https://medium.com/@sergiumneagu/laravel-why-youve-been-using-the-repository-pattern-the-wrong-way-952aedf1989b">Avoid breaking the Repository Design Pattern in Laravel</ExternalLink>, maintaining a clear separation between your domain logic and the persistence layer.
51
-
52
-
53
-
### CycleORM Features
54
-
-**Domain-Driven Design**: CycleORM is designed to work with complex domain models, making it a perfect fit for DDD.
55
-
-**Data Mapper**: CycleORM is a Data Mapper ORM, which means that it allows you to define your domain models and their relationships in a way that is more natural and expressive.
44
+
-**DataMapper Pattern:** Enforces a clear boundary between business logic and persistence, leading to a cleaner, more testable, and adaptable codebase, by defining your domain models and their relationships in a way that is more natural and expressive.
45
+
-**Designed for Complex Domains:** Provides the flexibility to model and manage intricate business rules and data relationships effectively.
46
+
-**Long-Term Maintainability:** By decoupling the domain model from persistence details, your application becomes less brittle and easier to maintain as requirements evolve.
47
+
-**Compatibility with Laravel Octane:** CycleORM is designed to work in daemonized PHP applications like <ExternalLinkhref="https://roadrunner.dev">RoadRunner</ExternalLink>, making it a good fit for <ExternalLinkhref="https://laravel.com/docs/11.x/octane">Laravel Octane</ExternalLink> users.
48
+
-**Database Factories**: Use Laravel database seeders together with <ExternalLinkhref="https://github.com/wayofdev/laravel-cycle-orm-factories">wayofdev/laravel-cycle-orm-factories</ExternalLink> to write Eloquent-Like factories for your CycleORM entities.
56
49
-**Powerful Query Builder**: CycleORM provides a powerful query builder that allows you to write complex queries in a way that is easy to read and understand.
57
50
-**Schema Management**: CycleORM provides powerful schema management capabilities, allowing you to define your database schema using PHP code.
51
+
-**Laravel Collections Support**: The adapter provides support for <ExternalLinkhref="https://laravel.com/docs/10.x/collections">Laravel Collections</ExternalLink>, allowing you to use them with your domain entities and repositories.
52
+
-**Flexible Entity Definition**: Use Plain Old PHP objects, <ExternalLinkhref="https://cycle-orm.dev/docs/advanced-active-record/current/en">ActiveRecord</ExternalLink>, Custom objects, or the <ExternalLinkhref="https://github.com/cycle/orm/tree/2.x/tests/ORM/Functional/Driver/Common/Classless">same entity type for multiple repositories.</ExternalLink>
53
+
-**Embedded Entities:** Work with embedded entities and lazy/eager loaded embedded partials.
54
+
-**Additional Features:** Supports global query scopes, UUIDs as primary keys, soft deletes, and auto timestamps.
55
+
-**Custom Column Types:** Allows the use of custom column types and foreign keys to non-primary columns.
56
+
-**Annotation Support:** Compatible with PHP8 attributes.
0 commit comments