PHPackages                             syeedalireza/architecture-patterns-lab - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. syeedalireza/architecture-patterns-lab

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

syeedalireza/architecture-patterns-lab
======================================

Academic research implementation of modern software architecture patterns. Comprehensive study of Clean Architecture, Hexagonal Architecture, and Onion Architecture with benchmarks, performance analysis, and real-world examples.

v1.0.0(3mo ago)00MITPHPPHP ^8.1|^8.2|^8.3CI failing

Since Jan 30Pushed 3mo agoCompare

[ Source](https://github.com/syeedalireza/architecture-patterns-lab)[ Packagist](https://packagist.org/packages/syeedalireza/architecture-patterns-lab)[ RSS](/packages/syeedalireza-architecture-patterns-lab/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (2)Used By (0)

Architecture Patterns Lab
=========================

[](#architecture-patterns-lab)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6687c1c3de3067b3e336e9f522a046f10625846acb404b5d014729b575f59250/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7379656564616c6972657a612f6172636869746563747572652d7061747465726e732d6c61622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/syeedalireza/architecture-patterns-lab)[![Total Downloads](https://camo.githubusercontent.com/8528e967d084dac416695e126c7bf6285f5fdb28311404548ff618ba77072c30/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7379656564616c6972657a612f6172636869746563747572652d7061747465726e732d6c61622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/syeedalireza/architecture-patterns-lab)[![GitHub Tests](https://camo.githubusercontent.com/bfd9af59a18ce0f27f20c1f0e7d1db5e7cae28f75f7f7e482f7afac160ae5686/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7379656564616c6972657a612f6172636869746563747572652d7061747465726e732d6c61622f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/syeedalireza/architecture-patterns-lab/actions)[![License](https://camo.githubusercontent.com/dd6c067979dae4144fa27ee3dd1455a4310aac7cdfefbd4864417d4e863cf561/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7379656564616c6972657a612f6172636869746563747572652d7061747465726e732d6c61622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/syeedalireza/architecture-patterns-lab)

**Academic research implementation of modern software architecture patterns.**

A comprehensive study and practical implementation of Clean Architecture, Hexagonal Architecture (Ports &amp; Adapters), and Onion Architecture patterns. This project provides reference implementations, performance benchmarks, architectural analysis, and real-world examples to help developers and researchers understand and apply these patterns effectively.

🎓 Academic Purpose
------------------

[](#-academic-purpose)

This project was developed as part of software engineering research to:

- Demonstrate practical implementation of theoretical architecture patterns
- Provide performance benchmarks comparing different architectural approaches
- Offer educational examples for learning advanced software design
- Document best practices and trade-offs in architectural decisions

📚 Architecture Patterns Implemented
-----------------------------------

[](#-architecture-patterns-implemented)

### 1. Clean Architecture (Uncle Bob's Architecture)

[](#1-clean-architecture-uncle-bobs-architecture)

- **Domain Layer**: Pure business logic, framework-independent
- **Application Layer**: Use cases and application services
- **Infrastructure Layer**: Framework, database, external services
- **Presentation Layer**: Controllers, CLI, API endpoints

### 2. Hexagonal Architecture (Ports &amp; Adapters)

[](#2-hexagonal-architecture-ports--adapters)

- **Domain**: Core business logic
- **Ports**: Interfaces defining contracts
- **Adapters**: Concrete implementations of ports
- **Primary Adapters**: Driving the application (HTTP, CLI)
- **Secondary Adapters**: Driven by application (Database, Email, Cache)

### 3. Onion Architecture

[](#3-onion-architecture)

- **Core**: Domain models and business rules
- **Services**: Domain services and business workflows
- **Infrastructure**: Technical implementations
- **Dependency Rule**: Inner layers never depend on outer layers

🚀 Features
----------

[](#-features)

- **Complete Pattern Implementations**: Full working examples of each architecture
- **Performance Benchmarks**: Detailed performance analysis and comparisons
- **Architectural Tests**: Automated tests to enforce architectural boundaries
- **Dependency Analysis**: Tools to visualize and validate dependencies
- **Real-World Examples**: E-commerce domain implementation in each pattern
- **Research Documentation**: Academic papers and detailed analysis
- **UML Diagrams**: Visual representations of each architecture
- **Migration Guides**: How to transition between patterns

📦 Installation
--------------

[](#-installation)

```
composer require syeedalireza/architecture-patterns-lab
```

🎯 Quick Start
-------------

[](#-quick-start)

### Clean Architecture Example

[](#clean-architecture-example)

```
use ArchitecturePatternsLab\CleanArchitecture\Application\UseCases\CreateOrder;
use ArchitecturePatternsLab\CleanArchitecture\Domain\Entities\Order;
use ArchitecturePatternsLab\CleanArchitecture\Infrastructure\Repositories\InMemoryOrderRepository;

// Infrastructure (outer layer)
$repository = new InMemoryOrderRepository();

// Application layer (use case)
$createOrder = new CreateOrder($repository);

// Execute use case
$order = $createOrder->execute([
    'customer_id' => '123',
    'items' => [
        ['product_id' => 'p1', 'quantity' => 2, 'price' => 29.99]
    ]
]);
```

### Hexagonal Architecture Example

[](#hexagonal-architecture-example)

```
use ArchitecturePatternsLab\HexagonalArchitecture\Domain\Order;
use ArchitecturePatternsLab\HexagonalArchitecture\Ports\OrderRepository;
use ArchitecturePatternsLab\HexagonalArchitecture\Adapters\PostgresOrderRepository;

// Primary Port (interface)
interface CreateOrderPort
{
    public function create(array $data): Order;
}

// Domain Service implements Port
class OrderService implements CreateOrderPort
{
    public function __construct(private OrderRepository $repository) {}

    public function create(array $data): Order
    {
        $order = new Order($data);
        $this->repository->save($order);
        return $order;
    }
}

// Secondary Adapter (infrastructure)
$repository = new PostgresOrderRepository($pdo);
$orderService = new OrderService($repository);

// Primary Adapter (HTTP Controller)
$order = $orderService->create($_POST);
```

### Onion Architecture Example

[](#onion-architecture-example)

```
use ArchitecturePatternsLab\OnionArchitecture\Core\Order;
use ArchitecturePatternsLab\OnionArchitecture\Services\OrderService;
use ArchitecturePatternsLab\OnionArchitecture\Infrastructure\OrderRepositoryImpl;

// Core domain
$order = Order::create('customer-123');

// Service layer
$orderService = new OrderService(
    new OrderRepositoryImpl()
);

// Execute business workflow
$result = $orderService->placeOrder($order);
```

📊 Performance Benchmarks
------------------------

[](#-performance-benchmarks)

Run benchmarks to compare patterns:

```
composer benchmark
```

### Sample Benchmark Results

[](#sample-benchmark-results)

PatternObject CreationRepository SaveUse Case ExecutionClean Architecture0.045ms1.234ms2.456msHexagonal Architecture0.042ms1.198ms2.312msOnion Architecture0.038ms1.156ms2.189ms*Note: Results may vary based on implementation details and hardware.*

🧪 Testing
---------

[](#-testing)

Run all tests:

```
composer test
```

Run with coverage:

```
composer test-coverage
```

### Architectural Testing

[](#architectural-testing)

Validate architectural boundaries:

```
composer architecture
```

This ensures:

- Domain layer has no framework dependencies
- Dependency rules are enforced
- No circular dependencies exist
- Proper layer isolation

📖 Documentation
---------------

[](#-documentation)

### Research Papers

[](#research-papers)

- [Comparative Analysis of Modern Architecture Patterns](docs/research/comparative-analysis.md)
- [Performance Implications of Layered Architectures](docs/research/performance-study.md)
- [Dependency Management in Hexagonal Architecture](docs/research/dependency-management.md)

### Architecture Diagrams

[](#architecture-diagrams)

See `docs/diagrams/` for:

- UML class diagrams
- Component diagrams
- Sequence diagrams
- Dependency graphs

### Detailed Guides

[](#detailed-guides)

- [Clean Architecture Implementation Guide](docs/guides/clean-architecture.md)
- [Hexagonal Architecture Best Practices](docs/guides/hexagonal-architecture.md)
- [Onion Architecture Patterns](docs/guides/onion-architecture.md)
- [Pattern Selection Guide](docs/guides/pattern-selection.md)

🔍 Architecture Comparison
-------------------------

[](#-architecture-comparison)

AspectClean ArchitectureHexagonal ArchitectureOnion Architecture**Complexity**MediumMedium-HighLow-Medium**Learning Curve**ModerateSteepGentle**Flexibility**HighVery HighMedium**Testability**ExcellentExcellentVery Good**Performance**GoodGoodVery Good**Best For**Enterprise appsComplex domainsDomain-rich apps**Team Size**Medium-LargeLargeSmall-Medium🎓 Educational Use
-----------------

[](#-educational-use)

This project is ideal for:

- **Students** learning software architecture
- **Developers** wanting to understand advanced patterns
- **Architects** evaluating pattern trade-offs
- **Researchers** studying software design
- **Teams** establishing architectural standards

📈 Use Cases
-----------

[](#-use-cases)

Each pattern is demonstrated with a complete e-commerce example including:

- Order management
- Product catalog
- User authentication
- Payment processing
- Inventory tracking
- Notification system

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! This is an academic project, and we value:

- New pattern implementations
- Performance optimizations
- Additional benchmarks
- Documentation improvements
- Bug fixes

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

📝 Citation
----------

[](#-citation)

If you use this project in academic research, please cite:

```
@software{architecture_patterns_lab,
  author = {Alireza Aminzadeh},
  title = {Architecture Patterns Lab: Comparative Study of Modern Software Architectures},
  year = {2024},
  url = {https://github.com/syeedalireza/architecture-patterns-lab}
}
```

📚 References
------------

[](#-references)

- Martin, R. C. (2017). *Clean Architecture*. Prentice Hall.
- Cockburn, A. (2005). *Hexagonal Architecture*. Alistair Cockburn Blog.
- Palermo, J. (2008). *The Onion Architecture*. Programming with Palermo.
- Evans, E. (2003). *Domain-Driven Design*. Addison-Wesley.
- Vernon, V. (2013). *Implementing Domain-Driven Design*. Addison-Wesley.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

👨‍🔬 Author
----------

[](#‍-author)

**Alireza Aminzadeh**

- Email:
- GitHub: [@syeedalireza](https://github.com/syeedalireza)
- Research: [Research Profile](#)

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

Special thanks to:

- Robert C. Martin (Uncle Bob) for Clean Architecture
- Alistair Cockburn for Hexagonal Architecture
- Jeffrey Palermo for Onion Architecture
- The DDD community for inspiration

---

**Note**: This is a research and educational project. While the implementations are production-quality, they are primarily intended for learning and reference purposes.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance81

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

101d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05de5f56c8b265c6720d5a4593d499a06c5a32b7ed2b7c36e0ac73778f09a381?d=identicon)[syeedalireza](/maintainers/syeedalireza)

---

Tags

phpDomain Driven Designddddesign patternsports and adaptersacademicclean architecturehexagonal-architectureresearchbenchmarksonion-architecturesoftware-architecturelayered-architecture

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/syeedalireza-architecture-patterns-lab/health.svg)

```
[![Health](https://phpackages.com/badges/syeedalireza-architecture-patterns-lab/health.svg)](https://phpackages.com/packages/syeedalireza-architecture-patterns-lab)
```

###  Alternatives

[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73142.3k25](/packages/jaxon-php-jaxon-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
