Skip to content

Commit 54d73e4

Browse files
authored
Merge pull request #600 from wayofdev/feat/docs
2 parents 43277ff + 0419442 commit 54d73e4

26 files changed

+3987
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/.build export-ignore
22
/.github export-ignore
3+
/docs export-ignore
34
/tests export-ignore
45
.editorconfig export-ignore
56
.env export-ignore

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.next
2+
node_modules

docs/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Nextra Docs Template
2+
3+
This is a template for creating documentation with [Nextra](https://nextra.site).
4+
5+
[**Live Demo →**](https://nextra-docs-template.vercel.app)
6+
7+
[![](.github/screenshot.png)](https://nextra-docs-template.vercel.app)
8+
9+
## Quick Start
10+
11+
Click the button to clone this repository and deploy it on Vercel:
12+
13+
[![](https://vercel.com/button)](https://vercel.com/new/clone?s=https%3A%2F%2Fgithub.com%2Fshuding%2Fnextra-docs-template&showOptionalTeamCreation=false)
14+
15+
## Local Development
16+
17+
First, run `pnpm i` to install the dependencies.
18+
19+
Then, run `pnpm dev` to start the development server and visit localhost:3000.
20+
21+
## License
22+
23+
This project is licensed under the MIT License.

docs/next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

docs/next.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const withNextra = require('nextra')({
2+
theme: 'nextra-theme-docs',
3+
themeConfig: './theme.config.tsx',
4+
})
5+
6+
module.exports = withNextra()

docs/package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@wayofdev/laravel-cycle-orm-adapter-docs",
3+
"version": "1.0.0",
4+
"description": "Documentation for Laravel Cycle ORM Adapter",
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/shuding/nextra-docs-template.git"
13+
},
14+
"author": "Shu Ding <[email protected]>",
15+
"license": "MIT",
16+
"bugs": {
17+
"url": "https://github.com/shuding/nextra-docs-template/issues"
18+
},
19+
"homepage": "https://github.com/shuding/nextra-docs-template#readme",
20+
"dependencies": {
21+
"next": "^13.5.6",
22+
"nextra": "latest",
23+
"nextra-theme-docs": "latest",
24+
"react": "^18.2.0",
25+
"react-dom": "^18.2.0"
26+
},
27+
"devDependencies": {
28+
"@types/node": "18.11.10",
29+
"autoprefixer": "^10.4.18",
30+
"postcss": "^8.4.35",
31+
"tailwindcss": "^3.4.1",
32+
"typescript": "^4.9.5"
33+
}
34+
}

docs/pages/_meta.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"index": "Introduction",
3+
"installation": "Installation",
4+
"configuration": "Configuration",
5+
"usage": "Usage",
6+
"services": "Services"
7+
}

docs/pages/configuration.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Configuration

docs/pages/index.mdx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Introduction
2+
3+
Unlock the full potential of [Domain-Driven Design](https://en.wikipedia.org/wiki/Domain-driven_design) in your Laravel projects with the [wayofdev/laravel-cycle-orm-adapter](https://github.com/wayofdev/laravel-cycle-orm-adapter) — the adapter package that seamlessly integrates the capabilities of [CycleORM](https://cycle-orm.dev) — DataMapper ORM into [Laravel Framework](https://laravel.com).
4+
5+
This adapter bridges the gap between Laravel's rapid development capabilities and Cycle ORM'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.
6+
7+
## 🧐 Understanding the Limitations of Eloquent
8+
9+
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.
10+
11+
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.
12+
13+
14+
## 🤔 Why CycleORM in Laravel?
15+
16+
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.
17+
18+
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.
19+
20+
There were many attempts to bring DDD to Laravel:
21+
22+
* [Laravel Beyond CRUD approach](https://laravel-beyond-crud.com) by Spatie
23+
24+
* [Conciliating Laravel and DDD](https://lorisleiva.com/conciliating-laravel-and-ddd) by Loris Leiva
25+
26+
* [Yet another Laravel 10 DDD interpretation](https://github.com/Orphail/laravel-ddd)
27+
28+
these often involve workarounds to adapt Eloquent rather than a fundamental shift in approach.
29+
30+
The `laravel-cycle-orm-adapter` bridges this gap, by introducing DataMapper pattern capabilities to Laravel, empowering you to unlock the full potential of DDD within your projects.
31+
32+
Here's why this combination shines:
33+
34+
* 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.
35+
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+
38+
* Long-Term Maintainability: By decoupling your domain model from persistence details, your application becomes less brittle and easier to maintain as requirements evolve.
39+
40+
41+
## 🚀 Features
42+
43+
### Laravel Cycle ORM Adapter Features
44+
- **Seamless Integration**: The adapter is designed to work seamlessly with Laravel, allowing you to use Cycle ORM in your Laravel projects without any hassle.
45+
- **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.
46+
- **Laravel Collections Support**: The adapter provides support for [Laravel Collections](https://laravel.com/docs/10.x/collections), allowing you to use them with your domain models and repositories
47+
- **Database Factories**: Use Laravel database seeders together with CycleORM Entity Factories via [wayofdev/laravel-cycle-orm-factories](https://github.com/wayofdev/laravel-cycle-orm-factories)
48+
- **Real Repositories**: [Avoid breaking the Repository Design Pattern in Laravel](https://medium.com/@sergiumneagu/laravel-why-youve-been-using-the-repository-pattern-the-wrong-way-952aedf1989b), maintaining a clear separation between your domain logic and the persistence layer.
49+
50+
51+
### Cycle ORM Features
52+
- **Domain-Driven Design**: Cycle ORM is designed to work with complex domain models, making it a perfect fit for DDD.
53+
- **Data Mapper**: Cycle ORM 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.
54+
- **Powerful Query Builder**: Cycle ORM provides a powerful query builder that allows you to write complex queries in a way that is easy to read and understand.
55+
- **Schema Management**: Cycle ORM provides powerful schema management capabilities, allowing you to define your database schema using PHP code.
56+
57+
## 🛠️ Want to see it in action?
58+
59+
Explore the Laravel CycleORM Starter Kit project: [laravel-cycle-orm-starter-kit](https://github.com/wayofdev/laravel-cycle-starter-tpl), based on Laravel 10.x. It showcases the practical use of the adapter in a real-world application, demonstrating how to leverage CycleORM's strengths within a Laravel project.

docs/pages/installation.mdx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Installation
2+
3+
Welcome to the installation guide for the Laravel Cycle ORM Adapter. This document will walk you through the setup process to get you up and running quickly.
4+
5+
## 🚩 Prerequisites
6+
7+
Before you begin, ensure your development environment meets the following requirements:
8+
9+
- **PHP Version:** 8.2 or higher
10+
- **Laravel:** 10.x or higher
11+
12+
## 🚀 Quick Start
13+
14+
Installing the Laravel Cycle ORM Adapter is straightforward with Composer. Follow the steps below to add the adapter to your Laravel project.
15+
16+
### Step 1: Install the Adapter
17+
18+
For the core functionality, run the following Composer command in your terminal:
19+
20+
```bash
21+
$ composer req wayofdev/laravel-cycle-orm-adapter
22+
```
23+
24+
This command installs the wayofdev/laravel-cycle-orm-adapter package, integrating Cycle ORM into your Laravel application.
25+
26+
### Step 2: Publish Configuration
27+
28+
After installing the package, publish the configuration file using the `vendor:publish` command:
29+
30+
```bash
31+
$ php artisan vendor:publish \
32+
--provider="WayOfDev\Cycle\Bridge\Laravel\Providers\CycleServiceProvider"
33+
```
34+
35+
## 🏭 Database Factories (Optional)
36+
37+
If you need support for [Eloquent-like Factories](https://laravel.com/docs/10.x/eloquent-factories), install the following package:
38+
39+
```bash
40+
$ composer req --dev wayofdev/laravel-cycle-orm-factories
41+
```
42+
43+
which will install the [wayofdev/laravel-cycle-orm-factories](https://github.com/wayofdev/laravel-cycle-orm-factories) package to provide similar functionality

0 commit comments

Comments
 (0)