# Development Environment

> Setting up a local development environment

---

What you need to build and test the module locally.

## Requirements

| Component | Version | Notes |
| --- | --- | --- |
| PHP | 8.3+ | same version the webtrees instance runs on |
| Composer | 2.x | installs `wt-shared-libs` + `phpstan` |
| Node.js | 18+ (LTS) | for Gulp / Rollup / Mocha |
| webtrees | 2.2.x or 2.3.x | needed for PHPStan (`app/` classes) and the smoke tests |
| [wt-shared-libs](../../wt-shared-libs) | newest version | sibling repo at `modules_v4/wt-shared-libs` (composer path repo) |

## Location

The module lives inside a webtrees installation at `modules_v4/linkenhancer/`. Its <a href="https://codeberg.org/bschwede/linkenhancer/src/branch/main/composer.json" target="_blank" rel="noopener"><code>composer.json</code></a>
 pulls in the sibling shared library as a local path repository:

```json
"repositories": [
    { "type": "path", "url": "../wt-shared-libs", "options": { "symlink": false } }
]
```

## Setup

```bash
# PHP dependencies (installs wt-shared-libs + phpstan)
composer install

# JS dependencies (gulp, rollup, mocha, …)
npm ci
```

> **Note:** <a href="https://codeberg.org/bschwede/linkenhancer/src/branch/main/composer.json" target="_blank" rel="noopener"><code>composer.json</code></a>
 sets `prepend-autoloader: false` — the module's autoloader is attached to (not replacing) webtrees' autoloader.

## Bind mount

In the current setup, development is being done on Linux with the Apache web server installed natively.The source tree is exposed to the PHP runtime through a bind mount of the rpo folders into `modules_v4`. Run the CLI tools and PHPStan from the **mount path** (the path the webtrees instance sees), not the source path, so `app/` and `vendor/autoload.php` resolve:

```bash
cd /path/to/webtrees/modules_v4/linkenhancer
composer analyse
```

See the [CLI Scripts](./cli-scripts) and [PHPStan](./phpstan) pages for the exact commands.
