Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The full documentation for the package is available at [https://laravel-cycle-or

<br>

## 🤝 Contributing
## 📥 Contributing

Contributions are welcome!

Expand Down
12 changes: 6 additions & 6 deletions config/cycle.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@
* Use any of channels configured in your logging.php file
*/
'logger' => [
'default' => env('DB_DEFAULT_LOGGER_CHANNEL', null),
'default' => env('DB_DEFAULT_LOGGER', null),
'drivers' => [
'sqlite' => env('DB_DEFAULT_LOGGER_CHANNEL', null),
'pgsql' => env('DB_DEFAULT_LOGGER_CHANNEL', null),
'mysql' => env('DB_DEFAULT_LOGGER_CHANNEL', null),
'sqlserver' => env('DB_DEFAULT_LOGGER_CHANNEL', null),
'sqlite' => env('DB_DEFAULT_LOGGER', null),
'pgsql' => env('DB_DEFAULT_LOGGER', null),
'mysql' => env('DB_DEFAULT_LOGGER', null),
'sqlserver' => env('DB_DEFAULT_LOGGER', null),
],
],
],
Expand Down Expand Up @@ -272,6 +272,6 @@
* @see https://github.com/cycle/entity-behavior
*/
'entityBehavior' => [
'register' => true,
'register' => env('CYCLE_REGISTER_ENTITY_BEHAVIOUR', true),
],
];
46 changes: 46 additions & 0 deletions docs/components/env-table/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import styles from './style.module.css'

export function OptionTable({ options }: { options: [string, string, string, string][] }) {
const createMarkup = (htmlContent) => {
return { __html: htmlContent };
};

return (
<div
className={
'-mx-6 mb-4 mt-6 overflow-x-auto overscroll-x-contain px-6 pb-4 ' +
styles.container
}
>
<table className="w-full border-collapse text-sm">
<thead>
<tr className="border-b py-4 text-left dark:border-neutral-700">
<th className="py-2 font-semibold">Environment Variable</th>
<th className="py-2 pl-6 font-semibold">Available Values</th>
<th className="py-2 pl-6 font-semibold">Default</th>
<th className="px-6 py-2 font-semibold">Description</th>
</tr>
</thead>
<tbody className="align-baseline text-gray-900 dark:text-gray-100">
{options.map(([variable, values, defaultValue, description]) => (
<tr
key={variable}
className="border-b border-gray-100 dark:border-neutral-700/50"
>
<td className="whitespace-pre py-2 font-mono text-xs font-semibold leading-6 text-violet-600 dark:text-violet-500">
{variable}
</td>
<td className="whitespace-pre py-2 pl-6 font-mono text-xs font-semibold leading-6 text-slate-500 dark:text-slate-400">
{values}
</td>
<td className="whitespace-pre py-2 pl-6 font-mono text-xs font-semibold leading-6 text-slate-500 dark:text-slate-400">
{defaultValue}
</td>
<td className="py-2 pl-6" dangerouslySetInnerHTML={createMarkup(description)}></td>
</tr>
))}
</tbody>
</table>
</div>
)
}
13 changes: 13 additions & 0 deletions docs/components/env-table/style.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.container {
mask-image: linear-gradient(
to right,
transparent 0.8em,
white 1.5em,
white calc(100% - 1.5em),
transparent calc(100% - 0.8em)
);
}

.container::-webkit-scrollbar {
appearance: none;
}
13 changes: 13 additions & 0 deletions docs/components/external-link/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { ArrowTopRightOnSquareIcon } from "@heroicons/react/20/solid";

const ExternalLink = ({ href, children }) => {
return (
<a href={href} target="_blank" className="nx-text-primary-600 nx-underline nx-decoration-from-font [text-underline-position:from-font] inline-flex items-center gap-0.5">
{children}
<ArrowTopRightOnSquareIcon className="size-4" />
</a>
);
};

export default ExternalLink;
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"homepage": "https://github.com/shuding/nextra-docs-template#readme",
"dependencies": {
"@heroicons/react": "^2.1.1",
"@vercel/analytics": "^1.2.2",
"next": "^14.1.3",
"nextra": "latest",
Expand Down
51 changes: 51 additions & 0 deletions docs/pages/configuration.mdx
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
import {
Callout
} from "nextra-theme-docs";
import {OptionTable} from "../components/env-table";

# Configuration

This section guides you through configuring the Laravel-CycleORM-Adapter package within your Laravel application. Configuration settings are managed in the `config/cycle.php` file. Ensure you have this file in your project by following the steps outlined in the [Installation](/installation) guide.

## 🌎 Environment Variables

### Database Connection Variables

This section details the environment variables for database connections. Our package uses Laravel's standard variables and introduces additional settings for CycleORM integration. Configure these in your `.env` file as needed or override them in your `config/cycle.php` file.

These are variables, that will be in `.env` file of your Laravel project from the box, and are used by `config/cycle.php` to configure CycleORM.

<OptionTable
options={[
["DB_CONNECTION", "string", "sqlite", "Database driver: `pgsql`, `mysql`, `sqlite`, `sqlserver`."],
["DB_HOST", "string", "127.0.0.1", "Database server hostname or IP."],
["DB_PORT", "integer", "by-driver", "The database port, driver specific."],
["DB_DATABASE", "string", "wod", "The database name."],
["DB_USERNAME", "string", "wod", "The database username."],
["DB_PASSWORD", "string", "wod", "The database password."]
]}
/>

### Additional Variables

These variables offer further customization for CycleORM's operation within Laravel.

<Callout type="info" emoji="💡">
Add these manually in your `.env` file to modify default behaviors, or use the `config/cycle.php` file to override them.
</Callout>

<OptionTable
options={[
["DB_DEFAULT_CONNECTION", "string", "default", "The default database connection."],
["DB_DEFAULT_LOGGER", "?string", "null", "Laravel logger channel, to log queries. Loggers can be added in `config/logging.php`"],
["DB_MIGRATIONS_TABLE", "string", "cycle_migrations", "The table name for the migrations."],
["CYCLE_TOKENIZER_CACHE_TARGETS", "boolean", "true", "Determines whether to cache located classes utilizing annotations."],
["CYCLE_TOKENIZER_LOAD_CLASSES", "boolean", "true", "Controls whether files of type `class` should be loaded."],
["CYCLE_TOKENIZER_LOAD_ENUMS", "boolean", "false", "Controls whether files of type `enum` should be loaded."],
["CYCLE_TOKENIZER_LOAD_INTERFACES", "boolean", "false", "Controls whether files of type `interface` should be loaded."],
["CYCLE_ATTRIBUTES_CACHE", "boolean", "true", "Determines whether located attributes should be cached."],
["CYCLE_ATTRIBUTES_CACHE_DRIVER", "string", "file", "Specifies the cache driver to use, selectable from the stores defined in `config/cache.php`."],
["DB_DEFAULT_COLLECTION", "string", "illuminate", "Sets the default collection implementation: `array`, `illuminate`, `doctrine`."],
["CYCLE_SCHEMA_WARMUP", "boolean", "true", "Indicates whether the schema cache should be preloaded."],
["CYCLE_REGISTER_ENTITY_BEHAVIOUR", "boolean", "true", "Enables support of `SoftDelete` and other behaviours from <a class=\"nx-text-primary-600 nx-underline nx-decoration-from-font [text-underline-position:from-font]\" target=\"_blank\" href=\"https://github.com/cycle/entity-behavior\">cycle/entity-behavior</a>"]
]}
/>
11 changes: 6 additions & 5 deletions docs/pages/contributing.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Callout } from 'nextra-theme-docs'
import ExternalLink from "../components/external-link";

# Contributing

Expand Down Expand Up @@ -28,8 +29,8 @@ The latest changes are always in master branch, so please make your Pull Request

## ✉️ Git Message Format

This repo adheres to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
Commit messages are enforced through [commitizen](https://github.com/commitizen-tools/commitizen) and a [pre-commit](https://pre-commit.com), please use `make hooks` to install them.
This repo adheres to the <ExternalLink href="https://www.conventionalcommits.org/en/v1.0.0/">Conventional Commits</ExternalLink> specification.
Commit messages are enforced through <ExternalLink href="https://github.com/commitizen-tools/commitizen">commitizen</ExternalLink> and a <ExternalLink href="https://pre-commit.com">pre-commit</ExternalLink>, please use `make hooks` to install them.

This leads to more readable messages that are easy to follow when looking through the project history and also allows to generate changelogs automatically.

Expand Down Expand Up @@ -61,15 +62,15 @@ $ make test

### → Static Analysis

Run Code quality checks using [PHPStan](https://phpstan.org):
Run Code quality checks using <ExternalLink href="https://phpstan.org">PHPStan</ExternalLink>:

```bash
$ make lint-stan
```

### → Coding Standards Fixing

Fix code using [The PHP Coding Standards Fixer](https://github.com/wayofdev/php-cs-fixer-config) to follow our standards:
Fix code using <ExternalLink href="https://github.com/wayofdev/php-cs-fixer-config">The PHP Coding Standards Fixer</ExternalLink> to follow our standards:

```bash
$ make lint-php
Expand All @@ -81,4 +82,4 @@ If you discover a security vulnerability within this package, please send an e-m

## 🤝 Code of Conduct

We are using the [Contributor Covenant](https://www.contributor-covenant.org/) as our Code of Conduct, to keep discussion open and inclusive. Please, take a moment to read and follow our [Code of Conduct](https://github.com/wayofdev/laravel-cycle-orm-adapter/blob/master/.github/CODE_OF_CONDUCT.md).
We are using the <ExternalLink href="https://www.contributor-covenant.org">Contributor Covenant</ExternalLink> as our Code of Conduct, to keep discussion open and inclusive. Please, take a moment to read and follow our <ExternalLink href="https://github.com/wayofdev/laravel-cycle-orm-adapter/blob/master/.github/CODE_OF_CONDUCT.md">Code of Conduct</ExternalLink>.
36 changes: 19 additions & 17 deletions docs/pages/index.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import ExternalLink from "../components/external-link";

# Introduction

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

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

## 🧐 Understanding the Limitations of Eloquent

Expand All @@ -19,15 +21,15 @@ The Active Record pattern tightly couples domain logic and data persistence with

There were many attempts to bring DDD to Laravel:

* [Laravel Beyond CRUD approach](https://laravel-beyond-crud.com) by Spatie
* <ExternalLink href="https://laravel-beyond-crud.com">Laravel Beyond CRUD approach</ExternalLink> by Spatie

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

* [Yet another Laravel 10 DDD interpretation](https://github.com/Orphail/laravel-ddd)
* <ExternalLink href="https://github.com/Orphail/laravel-ddd">Yet another Laravel 10 DDD interpretation</ExternalLink>

these often involve workarounds to adapt Eloquent rather than a fundamental shift in approach.

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

Here's why this combination shines:

Expand All @@ -40,20 +42,20 @@ Here's why this combination shines:

## 🚀 Features

### Laravel Cycle ORM Adapter Features
- **Seamless Integration**: The adapter is designed to work seamlessly with Laravel, allowing you to use Cycle ORM in your Laravel projects without any hassle.
### Laravel CycleORM Adapter Features
- **Seamless Integration**: The adapter is designed to work seamlessly with Laravel, allowing you to use CycleORM in your Laravel projects without any hassle.
- **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.
- **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
- **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)
- **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.
- **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
- **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>
- **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.


### Cycle ORM Features
- **Domain-Driven Design**: Cycle ORM is designed to work with complex domain models, making it a perfect fit for DDD.
- **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.
- **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.
- **Schema Management**: Cycle ORM provides powerful schema management capabilities, allowing you to define your database schema using PHP code.
### CycleORM Features
- **Domain-Driven Design**: CycleORM is designed to work with complex domain models, making it a perfect fit for DDD.
- **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.
- **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.
- **Schema Management**: CycleORM provides powerful schema management capabilities, allowing you to define your database schema using PHP code.

## 🛠️ Want to see it in action?

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.
Explore the Laravel CycleORM Starter Kit project: <ExternalLink href="https://github.com/wayofdev/laravel-cycle-starter-tpl">laravel-cycle-orm-starter-kit</ExternalLink>, 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.
20 changes: 11 additions & 9 deletions docs/pages/installation.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import ExternalLink from "../components/external-link";

# Installation

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.
Welcome to the installation guide for the Laravel CycleORM Adapter. This document will walk you through the setup process to get you up and running quickly.

## 🚩 Prerequisites

Expand All @@ -11,15 +13,15 @@ Before you begin, ensure your development environment meets the following requir

## 🧩 Compatibility Map

| Laravel | Cycle ORM | Adapter |
|---------|-----------|---------|
| ^10.28 | 2.x | 4.x |
| 11.x | 2.x | ^4.9.0 |
| Laravel | CycleORM | Adapter |
|---------|----------|---------|
| ^10.28 | 2.x | 4.x |
| 11.x | 2.x | ^4.9.0 |


## 🚀 Quick Start

Installing the Laravel Cycle ORM Adapter is straightforward with Composer. Follow the steps below to add the adapter to your Laravel project.
Installing the Laravel CycleORM Adapter is straightforward with Composer. Follow the steps below to add the adapter to your Laravel project.

<div className="steps-container">

Expand All @@ -31,7 +33,7 @@ For the core functionality, run the following Composer command in your terminal:
$ composer req wayofdev/laravel-cycle-orm-adapter
```

This command installs the wayofdev/laravel-cycle-orm-adapter package, integrating Cycle ORM into your Laravel application.
This command installs the wayofdev/laravel-cycle-orm-adapter package, integrating CycleORM into your Laravel application.

### Step: Publish Configuration

Expand All @@ -46,10 +48,10 @@ $ php artisan vendor:publish \

## 🏭 Database Factories (Optional)

If you need support for [Eloquent-like Factories](https://laravel.com/docs/10.x/eloquent-factories), install the following package:
If you need support for <ExternalLink href="https://laravel.com/docs/11.x/eloquent-factories">Eloquent-like Factories</ExternalLink>, install the following package:

```bash
$ composer req --dev wayofdev/laravel-cycle-orm-factories
```

which will install the [wayofdev/laravel-cycle-orm-factories](https://github.com/wayofdev/laravel-cycle-orm-factories) package to provide similar functionality
which will install the <ExternalLink href="https://github.com/wayofdev/laravel-cycle-orm-factories">wayofdev/laravel-cycle-orm-factories</ExternalLink> package to provide similar functionality
Loading