PHPackages                             kwidoo/hex-tools - 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. kwidoo/hex-tools

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

kwidoo/hex-tools
================

Laravel development tools for Hexagonal and Clean Architecture projects.

v1.4(1mo ago)02MITPHPPHP ^8.2CI failing

Since May 4Pushed 1mo agoCompare

[ Source](https://github.com/kwidoo/hex-tools)[ Packagist](https://packagist.org/packages/kwidoo/hex-tools)[ RSS](/packages/kwidoo-hex-tools/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (7)Versions (16)Used By (0)

Hex Tools
=========

[](#hex-tools)

[![CI](https://github.com/kwidoo/hex-tools/actions/workflows/ci.yml/badge.svg)](https://github.com/kwidoo/hex-tools/actions/workflows/ci.yml)[![License: MIT](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/0f16581d1180dbfd4c0e13166ec1267d4ad2f2fab8281ea6d6b284cf5c65d921/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d626c75652e737667)](https://www.php.net)[![Laravel](https://camo.githubusercontent.com/cda3a3caf1337c6e594a2b1be6a3166edf268a87d7254f5c4c82f1483814c1d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d313125323025374325323031322d7265642e737667)](https://laravel.com)

`kwidoo/hex-tools` is a pragmatic Laravel/PHP toolkit for generating, inspecting, documenting, and enforcing hexagonal architecture boundaries.

**Supported Versions:** Laravel 11, 12 | PHP 8.2+

> **TODO:** Laravel 13 support is planned for a future release.

Installation
------------

[](#installation)

```
composer require --dev kwidoo/hex-tools
composer require --dev deptrac/deptrac

php artisan hex:install
php artisan hex:deptrac:layers
php artisan hex:deptrac:modules
```

Commands
--------

[](#commands)

CommandDescription`hex:install`Publish config, create docs/build folders, optionally install composer scripts`hex:deptrac:layers`Generate `deptrac.layers.yaml` for strict technical layer checks`hex:deptrac:modules`Generate `deptrac.modules.yaml` for business module boundary checks`hex:map {module}`Print grouped class map for a module`hex:inspect`Inspect modules, layers, dependencies, and architecture issues`hex:doctor`Check package configuration and quality-tooling health`hex:docs`Generate architecture intelligence documentation`hex:baseline`Baseline current architecture issues for legacy projects`hex:explain {rule}`Explain a known architecture rule code`hex:module:init {module}`Create module folder skeleton and docs stub`hex:docs:generate`Generate architecture documentation from config`hex:adr:create {title}`Create a numbered Architecture Decision RecordLayer config vs Module config
-----------------------------

[](#layer-config-vs-module-config)

**`deptrac.layers.yaml`** enforces technical layer boundaries:

- `Domain` may only depend on itself
- `Application` may depend on `Domain`
- `Http` may depend on `Application`, `Domain`, framework, and vendor
- `Infrastructure` may depend on `Application`, `Domain`, `Models`, framework, and vendor
- `Models` may depend on `Domain`, framework, and vendor

This prevents technical violations like `Http -> Models` or `Domain -> Eloquent`.

**`deptrac.modules.yaml`** enforces business module boundaries:

Each module (e.g. `Product`, `Order`) is collected from all technical layers but treated as a single unit. Rules define which modules may depend on which others.

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=hex-tools-config
```

Edit `config/hex-tools.php` to define your modules and allowed dependencies.

### Module Configuration

[](#module-configuration)

The package uses a neutral default configuration with example modules. You should replace these with your own business domain modules:

```
// config/hex-tools.php

'modules' => [
    // Define your business modules here
    'User',
    'Product',
    'Order',
    'Payment',
    'Shared',  // Common utilities shared across modules
],

'module_rules' => [
    // Define which modules each module can depend on
    'Shared' => ['Shared'],
    'User' => ['User', 'Shared'],
    'Product' => ['Product', 'Shared'],
    'Order' => ['Order', 'Product', 'User', 'Shared'],
    'Payment' => ['Payment', 'Order', 'User', 'Shared'],
],
```

**Guidelines:**

- Each module represents a bounded context in your domain
- The `Shared` module is typically used for common code that other modules can depend on
- A module may depend on itself implicitly (no need to list it)
- Avoid circular dependencies between modules

Example
-------

[](#example)

```
# Show architecture map for Product module
php artisan hex:map Product

# Generate architecture checks
composer hex:layers
composer hex:modules

# Inspect a specific module membership in Deptrac
vendor/bin/deptrac debug:layer --config-file=deptrac.modules.yaml Product

# Check if Product depends on Pickup
vendor/bin/deptrac debug:dependencies --config-file=deptrac.modules.yaml Product Pickup

# Find unassigned classes
vendor/bin/deptrac debug:unassigned --config-file=deptrac.modules.yaml

# Create a new module skeleton
php artisan hex:module:init NewModule --with-folders

# Create an Architecture Decision Record
php artisan hex:adr:create "Domain must not use Eloquent" --status=accepted
```

Architecture Intelligence
-------------------------

[](#architecture-intelligence)

```
php artisan hex:inspect --format=json
php artisan hex:inspect --module=Product --fail-on-violations
php artisan hex:doctor --strict
php artisan hex:docs --output=docs/architecture --force
php artisan hex:baseline --output=.hex/baseline/architecture.json
php artisan hex:explain domain_depends_on_framework
```

`hex:inspect` analyzes source structure and reports conservative rule violations such as Domain depending on framework or Infrastructure code. `hex:doctor` checks setup health, including config files, quality tooling, CI workflow, module paths, and composer scripts. `hex:baseline` stores stable hashes for current issues so future inspections can distinguish existing baseline issues from new ones.

PHPMD
-----

[](#phpmd)

Hex Tools can generate a Laravel-friendly PHPMD ruleset.

Install PHPMD:

```
composer require --dev phpmd/phpmd
```

Generate config:

```
php artisan hex:phpmd:install
php artisan hex:phpmd:install --composer-scripts
```

Run:

```
composer md
composer md:domain
composer md:application
```

Generate baseline for existing projects:

```
composer md:baseline
```

CommandDescription`hex:phpmd:install`Install PHPMD ruleset and optional composer scripts`hex:phpmd:generate`Regenerate PHPMD ruleset`hex:phpmd:baseline`Print or run PHPMD baseline generation`hex:phpmd:run`Run PHPMD using generated rulesPHPStan/Larastan
----------------

[](#phpstanlarastan)

Hex Tools can generate PHPStan/Larastan configs for Laravel Hexagonal Architecture projects.

```
composer require --dev larastan/larastan

php artisan hex:phpstan:install
php artisan hex:phpstan:install --composer-scripts
```

Generated configs:

- `phpstan.neon.dist`
- `phpstan-domain.neon`
- `phpstan-application.neon`

Run:

```
composer stan
composer stan:domain
composer stan:application
```

CommandDescription`hex:phpstan:install`Install PHPStan configs and optional composer scripts`hex:phpstan:generate`Regenerate PHPStan config files`hex:phpstan:baseline`Print or run PHPStan baseline generationLicense
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance93

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

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

Every ~0 days

Total

5

Last Release

35d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1534033?v=4)[Sam Brown](/maintainers/samsite)[@samsite](https://github.com/samsite)

---

Top Contributors

[![kwidoo](https://avatars.githubusercontent.com/u/14920653?v=4)](https://github.com/kwidoo "kwidoo (18 commits)")[![qwen-intl](https://avatars.githubusercontent.com/u/223635574?v=4)](https://github.com/qwen-intl "qwen-intl (9 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/kwidoo-hex-tools/health.svg)

```
[![Health](https://phpackages.com/badges/kwidoo-hex-tools/health.svg)](https://phpackages.com/packages/kwidoo-hex-tools)
```

###  Alternatives

[laravel/sail

Docker files for running a basic Laravel application.

1.9k199.2M1.2k](/packages/laravel-sail)[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)[spatie/laravel-export

Create a static site bundle from a Laravel app

670139.5k6](/packages/spatie-laravel-export)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

719160.4k12](/packages/tallstackui-tallstackui)[flarum/core

Delightfully simple forum software.

261.4M2.2k](/packages/flarum-core)

PHPackages © 2026

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