Skip to content

Commit 3a2dce3

Browse files
authored
Merge pull request #623 from wayofdev/feat/docs
2 parents 95c1e60 + 9a59026 commit 3a2dce3

File tree

5 files changed

+89
-29
lines changed

5 files changed

+89
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Created in **2022** by [lotyp / wayofdev](https://github.com/wayofdev)
8585

8686
* The official [spiral/cycle-bridge](https://github.com/spiral/cycle-bridge) for Spiral Framework
8787

88-
* Alternative implementation of Cycle ORM for Laravel — [wakebit/laravel-cycle](https://github.com/wakebit/laravel-cycle) (abandoned)
88+
* Alternative implementation of Cycle ORM for Laravel — [wakebit/laravel-cycle](https://github.com/wakebit/laravel-cycle)
8989

9090

9191
<br>

docs/components/env-table/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styles from './style.module.css'
22

33
export function OptionTable({ options }: { options: [string, string, string, string][] }) {
4-
const createMarkup = (htmlContent) => {
4+
const createMarkup = (htmlContent: string) => {
55
return { __html: htmlContent };
66
};
77

docs/pages/index.mdx

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,58 @@ import ExternalLink from "../components/external-link";
22

33
# Introduction
44

5-
Unlock the full potential of Domain-Driven Design in your Laravel projects with the <ExternalLink href="https://github.com/wayofdev/laravel-cycle-orm-adapter">laravel-cycle-orm-adapter</ExternalLink> — the adapter package that seamlessly integrates the capabilities of <ExternalLink href="https://cycle-orm.dev">CycleORM</ExternalLink> DataMapper ORM into <ExternalLink href="https://laravel.com">Laravel Framework</ExternalLink>.
5+
Unlock the full potential of Domain-Driven Design in your Laravel projects with the <ExternalLink href="https://github.com/wayofdev/laravel-cycle-orm-adapter">laravel-cycle-orm-adapter</ExternalLink> — the adapter package that seamlessly integrates the capabilities of <ExternalLink href="https://cycle-orm.dev">CycleORM</ExternalLink> DataMapper ORM into <ExternalLink href="https://laravel.com">Laravel Framework</ExternalLink>.
66

77
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.
88

99
## 🧐 Understanding the Limitations of Eloquent
1010

11-
While Eloquent is 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
1212

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.
1414

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.
1516

1617
## 🤔 Why CycleORM in Laravel?
1718

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:
2320

2421
* <ExternalLink href="https://laravel-beyond-crud.com">Laravel Beyond CRUD approach</ExternalLink> by Spatie
2522

2623
* <ExternalLink href="https://lorisleiva.com/conciliating-laravel-and-ddd">Conciliating Laravel and DDD</ExternalLink> by Loris Leiva
2724

2825
* <ExternalLink href="https://github.com/Orphail/laravel-ddd">Yet another Laravel 10 DDD interpretation</ExternalLink>
2926

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.
3128

32-
The <ExternalLink href="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 <ExternalLink href="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.
3331

3432
Here's why this combination shines:
3533

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.
4138

39+
## 🌟 Key Features
4240

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 <ExternalLink href="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 <ExternalLink href="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.
5043
- **Real Repositories**: <ExternalLink href="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 <ExternalLink href="https://roadrunner.dev">RoadRunner</ExternalLink>, making it a good fit for <ExternalLink href="https://laravel.com/docs/11.x/octane">Laravel Octane</ExternalLink> users.
48+
- **Database Factories**: Use Laravel database seeders together with <ExternalLink href="https://github.com/wayofdev/laravel-cycle-orm-factories">wayofdev/laravel-cycle-orm-factories</ExternalLink> to write Eloquent-Like factories for your CycleORM entities.
5649
- **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.
5750
- **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 <ExternalLink href="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, <ExternalLink href="https://cycle-orm.dev/docs/advanced-active-record/current/en">ActiveRecord</ExternalLink>, Custom objects, or the <ExternalLink href="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.
5857

5958
## 🛠️ Want to see it in action?
6059

docs/pages/services.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Card, Cards } from 'nextra/components'
2+
3+
# Services
4+
5+
<Cards>
6+
<Card
7+
title="Factories"
8+
href="/services/factories"
9+
children=""
10+
icon=""/>
11+
<Card
12+
title="Seeders"
13+
href="/services/seeders"
14+
children=""
15+
icon=""/>
16+
<Card
17+
title="Testing"
18+
href="/services/testing"
19+
children=""
20+
icon=""/>
21+
<Card
22+
title="Validation"
23+
href="/services/validation"
24+
children=""
25+
icon=""/>
26+
</Cards>

docs/pages/usage.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
1+
import { Card, Cards } from 'nextra/components'
2+
13
# Usage
4+
5+
<Cards>
6+
<Card
7+
title="Attributes (Annotations)"
8+
href="/usage/attributes"
9+
children=""
10+
icon=""/>
11+
<Card
12+
title="Console Commands"
13+
href="/usage/console-commands"
14+
children=""
15+
icon=""/>
16+
<Card
17+
title="Entities"
18+
href="/usage/entities"
19+
children=""
20+
icon=""/>
21+
<Card
22+
title="Entity Manager"
23+
href="/usage/entity-manager"
24+
children=""
25+
icon=""/>
26+
<Card
27+
title="Migrations"
28+
href="/usage/migrations"
29+
children=""
30+
icon=""/>
31+
<Card
32+
title="Repositories"
33+
href="/usage/repositories"
34+
children=""
35+
icon=""/>
36+
</Cards>

0 commit comments

Comments
 (0)