Skip to content

Commit c011e3a

Browse files
committed
feat: update contributing guidelines and enhance documentation clarity
1 parent 721a93a commit c011e3a

6 files changed

Lines changed: 219 additions & 169 deletions

File tree

CONTRIBUTING.md

Lines changed: 57 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,177 +1,113 @@
1-
# Contributing to DDLess Engine
1+
# Contributing
22

3-
Thanks for your interest in contributing! This document explains how to get started.
3+
## Setup
44

5-
## Getting Started
5+
Clone your fork at the root of a PHP project (alongside `composer.json`):
66

7-
1. Fork this repository
8-
2. Clone your fork at the root of a PHP project:
9-
```bash
10-
cd /var/www/html # your project root (must have composer.json)
11-
git clone https://github.com/YOUR_USER/ddless-engine.git
12-
cd ddless-engine
13-
```
14-
3. Make sure tests pass before making changes:
15-
```bash
16-
php tests/run-all.php
17-
```
18-
19-
## PHP Version Compatibility
20-
21-
All code **must** work on PHP 7.4 through 8.4. This means:
22-
23-
- No `mixed` type hints (use `#[\ReturnTypeWillChange]` where needed)
24-
- No named arguments in function calls
25-
- No `match` expressions
26-
- No enums (the engine detects them at runtime with `instanceof`)
27-
- No union types in signatures
28-
- No `readonly` properties
29-
- No fibers
30-
31-
If you're unsure whether a feature is available on 7.4, check [php.net/migration80](https://www.php.net/migration80).
7+
```bash
8+
cd /var/www/html
9+
git clone https://github.com/YOUR_USER/ddless-engine.git
10+
cd ddless-engine
11+
php tests/run-all.php # make sure everything passes first
12+
```
3213

33-
## Project Structure
14+
## PHP compatibility
3415

35-
```
36-
src/
37-
debug.php # Core engine (AST analysis, instrumentation, breakpoints)
38-
http_trigger.php # HTTP debug entry point
39-
method_trigger.php # Method debug entry point
40-
task_trigger.php # Task debug entry point
41-
cli_trigger.php # CLI debug entry point
42-
frameworks/
43-
laravel/ # Laravel-specific handlers
44-
symfony/ # Symfony-specific handlers
45-
codeigniter/ # CodeIgniter 4 handlers
46-
tempest/ # Tempest handlers
47-
wordpress/ # WordPress handlers
48-
php/ # Vanilla PHP handlers (minimal reference)
49-
playground/ # Interactive terminal test suite
50-
vendor-internal/ # Bundled PHP-Parser (do not modify)
51-
tests/
52-
bootstrap.php # Test runner and assertions
53-
run-all.php # Runs all test files
54-
*Test.php # Individual test files
55-
```
16+
All code must run on PHP 7.4 through 8.4. That means no:
5617

57-
## Playground — Testing Your Changes
18+
- `mixed` type hints (use `#[\ReturnTypeWillChange]` where needed)
19+
- named arguments, `match`, union types, `readonly`, enums, fibers
5820

59-
The playground lets you test the debug engine and framework integrations directly
60-
from the terminal, without the DDLess desktop app. Use it to validate your changes
61-
before submitting a PR.
21+
When in doubt: [php.net/migration80](https://www.php.net/migration80).
6222

63-
### Setup
23+
## Playground
6424

65-
Clone ddless-engine **at the root of a real PHP project** (alongside `composer.json`):
25+
The playground lets you test the engine and framework integrations from the terminal, without the desktop app. It expects ddless-engine to live inside a real PHP project:
6626

6727
```
68-
/var/www/html/ ← your project root (has composer.json)
28+
/var/www/html/ ← project root (has composer.json)
6929
├── app/
7030
├── vendor/
7131
├── composer.json
72-
└── ddless-engine/ ← clone here
73-
└── src/
74-
├── debug.php
75-
├── frameworks/
76-
└── playground/
32+
└── ddless-engine/ ← your fork
7733
```
7834

79-
```bash
80-
cd /var/www/html # go to your project root
81-
git clone https://github.com/YOUR_USER/ddless-engine.git
82-
cd ddless-engine # all playground commands run from here
83-
```
84-
85-
The playground auto-detects your project root by looking for `composer.json`
86-
one directory above `ddless-engine/`. All breakpoint paths (e.g.
87-
`app/Services/OrderService.php:38`) resolve relative to that project root.
35+
Each step validates a layer. If one fails, you know exactly where to look.
8836

89-
### Step 1 — Engine Test
37+
### Engine test
9038

91-
Validates the core debug engine (breakpoints, stepping, variable inspection).
39+
Validates breakpoints, stepping, and variable inspection:
9240

9341
```bash
94-
# Quick sanity check — no framework
9542
php src/playground/test_trigger.php --code '$x = 1; $y = 2; echo $x + $y;' --bp 2
9643
```
9744

98-
To test with a framework, create two files inside the ddless-engine directory:
45+
With a framework, create `boot.php` and a test file:
9946

100-
**boot.php** — boots the framework (runs without stream wrapper):
10147
```php
48+
// boot.php — boots the framework (runs without stream wrapper)
10249
<?php
103-
define('DDLESS_PROJECT_ROOT', dirname(__DIR__)); // points to actual project root
50+
define('DDLESS_PROJECT_ROOT', dirname(__DIR__));
10451
require __DIR__ . '/../vendor/autoload.php';
10552
$app = require __DIR__ . '/../bootstrap/app.php';
10653
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
10754
```
10855

109-
**test_orders.php** — what you want to test:
11056
```php
57+
// test_orders.php
11158
<?php
11259
$service = app(\App\Services\OrderService::class);
11360
$result = $service->calculate(42);
11461
var_dump($result);
11562
```
11663

11764
```bash
118-
# Run with breakpoints inside the service code
11965
php src/playground/test_trigger.php --boot boot.php --file test_orders.php \
12066
--bp app/Services/OrderService.php:38
12167
```
12268

123-
`DDLESS_PROJECT_ROOT` in boot.php must point to your actual project root so that
124-
breakpoint paths like `app/Services/OrderService.php:38` resolve correctly.
125-
126-
This is the first test when adding a new framework. If the boot works and breakpoints
127-
hit inside framework code, you understand the bootstrap — and can replicate it in
128-
the handlers.
129-
130-
### Step 2 — Method Test
69+
### Method test
13170

132-
Validates a framework's `method_executor.php` — resolves a class from the container
133-
and calls a method:
71+
Validates `method_executor.php` — resolves a class from the container and calls a method:
13472

13573
```bash
13674
php src/playground/test_trigger.php --test method --framework laravel \
13775
--class "App\Services\OrderService" --method calculate
13876

139-
# With parameters
77+
# with parameters
14078
php src/playground/test_trigger.php --test method --framework laravel \
14179
--class "App\Services\OrderService" --method calculate \
14280
--params-file test_params.php
14381

144-
# With breakpoints
82+
# with breakpoints
14583
php src/playground/test_trigger.php --test method --framework laravel \
14684
--class "App\Services\OrderService" --method calculate \
14785
--bp app/Services/OrderService.php:45
14886
```
14987

150-
### Step 3 — Task Test
88+
### Task test
15189

152-
Validates a framework's `task_runner.php` — executes arbitrary PHP code with
153-
framework context:
90+
Validates `task_runner.php` — executes PHP code with framework context:
15491

15592
```bash
15693
php src/playground/test_trigger.php --test task --framework laravel \
15794
-c '$this->info("Users: " . User::count());' \
15895
-u "App\Models\User"
15996

160-
# From a file
97+
# from a file
16198
php src/playground/test_trigger.php --test task --framework laravel \
16299
--file my_task.php
163100
```
164101

165-
### Step 4 — HTTP Test
102+
### HTTP test
166103

167-
Validates a framework's `http_request.php` — sends real HTTP requests through
168-
the full pipeline:
104+
Validates `http_request.php` — sends real requests through the full pipeline:
169105

170106
**Terminal 1:**
171107
```bash
172108
DDLESS_FRAMEWORK=laravel php -S localhost:8080 src/playground/test_trigger.php
173109

174-
# With breakpoints
110+
# with breakpoints
175111
DDLESS_FRAMEWORK=laravel DDLESS_BP="app/Http/Controllers/OrderController.php:45" \
176112
php -S localhost:8080 src/playground/test_trigger.php
177113
```
@@ -183,30 +119,23 @@ curl -X POST http://localhost:8080/api/orders \
183119
-H "Content-Type: application/json" -d '{"item":"test"}'
184120
```
185121

186-
Each step validates a layer. If one fails, you know exactly where to look.
187-
See `src/playground/README.md` for full details and all options.
188-
189-
## Adding a New Framework
190-
191-
To add support for a new framework (e.g. CakePHP):
122+
See `src/playground/README.md` for all options and protocols.
192123

193-
1. Create `src/frameworks/cakephp/` with three files:
124+
## Adding a framework
194125

195-
| File | Purpose |
196-
|------|---------|
197-
| `method_executor.php` | Resolve class from container, call method, output result |
198-
| `task_runner.php` | Boot framework, eval user code with `DdlessTask` context |
199-
| `http_request.php` | Process HTTP request through full middleware pipeline |
126+
To add support for a new framework (e.g. CakePHP), create `src/frameworks/cakephp/` with:
200127

201-
2. Use `src/frameworks/php/` as a minimal reference and `src/frameworks/laravel/` as a full example.
128+
| File | Purpose |
129+
|------|---------|
130+
| `method_executor.php` | Resolve class from container, call method, output result |
131+
| `task_runner.php` | Boot framework, eval user code with `DdlessTask` context |
132+
| `http_request.php` | Process HTTP request through the full middleware pipeline |
202133

203-
3. Test with the playground (Steps 2, 3, 4 above).
134+
Use `src/frameworks/php/` as a minimal reference and `src/frameworks/laravel/` as a full one. Validate with the playground steps above.
204135

205-
4. See `src/playground/README.md` for input/output protocols of each handler.
136+
## Writing tests
206137

207-
## Writing Tests
208-
209-
Tests use a zero-dependency mini test runner defined in `tests/bootstrap.php`.
138+
Tests use a zero-dependency runner defined in `tests/bootstrap.php`:
210139

211140
```php
212141
<?php
@@ -230,22 +159,21 @@ if (basename(__FILE__) === basename($_SERVER['SCRIPT_FILENAME'] ?? '')) {
230159

231160
Available assertions: `assert_eq`, `assert_true`, `assert_false`, `assert_null`, `assert_not_null`, `assert_contains`, `assert_not_contains`, `assert_array_has_key`, `assert_array_not_has_key`, `assert_count`.
232161

233-
## Submitting Changes
234-
235-
1. Create a branch from `main`
236-
2. Write or update tests for your changes
237-
3. Test with the playground to validate framework integrations
238-
4. Make sure all tests pass: `php tests/run-all.php`
239-
5. Open a Pull Request with a clear description of what you changed and why
162+
## Submitting changes
240163

241-
## What Not to Modify
164+
1. Branch from `main`
165+
2. Write or update tests
166+
3. Validate with the playground
167+
4. `php tests/run-all.php` — all green
168+
5. Open a PR with a clear description of what and why
242169

243-
- `src/vendor-internal/` — This is a bundled copy of nikic/PHP-Parser. Changes here will be overwritten.
170+
## Don't modify
244171

245-
## Reporting Issues
172+
`src/vendor-internal/` is a bundled copy of nikic/PHP-Parser. Changes will be overwritten.
246173

247-
Open an issue on this repository. Include:
174+
## Reporting issues
248175

176+
Open an issue with:
249177
- PHP version (`php -v`)
250-
- A minimal code snippet that reproduces the problem
178+
- Minimal reproduction snippet
251179
- Expected vs actual behavior

README.md

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,65 @@
1-
# DDLess PHP Debug Engine
1+
# ddless-engine
22

33
![Tests](https://github.com/behindSolution/ddless-engine/actions/workflows/tests.yml/badge.svg)
44

5-
> **This is the PHP engine only.** For the full debugging experience (desktop app, UI, AI Copilot, Task Runner), visit [ddless.com](https://ddless.com)
5+
The PHP runtime engine behind [DDLess](https://ddless.com) — a visual step-through debugger for PHP.
66

7-
The PHP runtime engine that powers [DDLess](https://ddless.com) — a visual debugger for PHP applications.
7+
This repo contains the engine only. The desktop app, UI, and AI Copilot are available at [ddless.com](https://ddless.com).
88

9-
This engine handles code instrumentation, breakpoint management, step-through execution, and variable inspection. It works with any PHP project (vanilla PHP, Laravel, Symfony, etc.) running on PHP 7.4+.
9+
## What it does
1010

11-
## How It Works
11+
ddless-engine parses PHP source via AST ([nikic/PHP-Parser](https://github.com/nikic/PHP-Parser)), injects `ddless_step_check()` calls before each executable line using a custom stream wrapper, and communicates with the desktop app through file-based IPC. Your original files are never modified on disk.
1212

13-
DDLess uses AST-based analysis (via [nikic/PHP-Parser](https://github.com/nikic/PHP-Parser)) to understand your code structure. It injects step-check calls before each executable line, allowing the debugger to pause, inspect variables, and control execution flow — all without modifying your original files.
13+
Supports breakpoints (conditional, logpoints, dumppoints), step-in/over/out, watch expressions, variable inspection, and trace mode.
1414

15-
### Core Components
15+
## Frameworks
1616

17-
| File | Purpose |
18-
|------|---------|
19-
| `src/debug.php` | Main engine — AST analysis, instrumentation, breakpoint handler, variable serialization |
20-
| `src/http_trigger.php` | Entry point for HTTP debug sessions |
21-
| `src/method_trigger.php` | Entry point for method-level debugging |
22-
| `src/task_trigger.php` | Entry point for task/command debugging |
23-
| `src/cli_trigger.php` | Entry point for CLI script debugging |
24-
| `src/frameworks/laravel/` | Laravel-specific request handling, method execution, task runner |
25-
| `src/frameworks/symfony/` | Symfony request handling, method execution, task runner |
26-
| `src/frameworks/codeigniter/` | CodeIgniter 4 request handling, method execution, task runner |
27-
| `src/frameworks/tempest/` | Tempest request handling, method execution, task runner |
28-
| `src/frameworks/wordpress/` | WordPress request handling, method execution, task runner |
29-
| `src/frameworks/php/` | Vanilla PHP request handling, method execution, task runner |
30-
| `src/vendor-internal/` | Bundled PHP-Parser (no Composer required) |
17+
Laravel · Symfony · CodeIgniter 4 · Tempest · WordPress · vanilla PHP
3118

32-
### Key Functions
19+
## Project layout
3320

34-
- `ddless_analyze_code_ast()` — Parses PHP source into AST and identifies instrumentable lines
35-
- `ddless_instrument_code_with_ast()` — Injects debug hooks into source code
36-
- `ddless_step_check()` — Called before every executable line, decides whether to pause
37-
- `ddless_handle_breakpoint()` — Pauses execution, captures state, waits for debugger command
38-
- `ddless_normalize_value()` — Serializes variables for display (handles objects, enums, DateTime, etc.)
21+
```
22+
src/
23+
├── debug.php Core engine (AST analysis, instrumentation, breakpoint handler)
24+
├── http_trigger.php Entry point for HTTP debug sessions
25+
├── method_trigger.php Entry point for method-level debugging
26+
├── cli_trigger.php Entry point for CLI script debugging
27+
├── task_trigger.php Entry point for task/command debugging
28+
├── ssh_proxy_router.php SSH remote debugging support
29+
├── frameworks/ Framework-specific request handling and bootstrapping
30+
│ ├── laravel/
31+
│ ├── symfony/
32+
│ ├── codeigniter/
33+
│ ├── tempest/
34+
│ ├── wordpress/
35+
│ └── php/
36+
├── sessions/ File-based IPC (runtime ↔ desktop app)
37+
├── cache/ Pre-instrumented code cache
38+
└── vendor-internal/ Bundled PHP-Parser (no Composer required)
39+
```
3940

4041
## Requirements
4142

42-
- PHP 7.4 or higher (tested up to 8.4)
43-
- `json` extension (included by default)
43+
- PHP 7.4+ (tested up to 8.4)
44+
- `json` extension (ships with PHP by default)
45+
- No external dependencies
4446

45-
## Running Tests
47+
## Tests
4648

4749
```bash
4850
php tests/run-all.php
4951
```
5052

51-
Individual test files can also be run directly:
53+
Or run individually:
5254

5355
```bash
5456
php tests/NormalizeValueTest.php
5557
php tests/InstrumentCodeAstTest.php
5658
php tests/HttpRequestTest.php
5759
```
5860

59-
## Test Matrix
60-
61-
Tests run automatically on every push and PR against PHP 7.4, 8.0, 8.1, 8.2, 8.3, and 8.4.
61+
CI runs against PHP 7.4, 8.0, 8.1, 8.2, 8.3, and 8.4 on every push and PR.
6262

6363
## License
6464

65-
Source-available. You may read, audit, and report issues.
66-
Redistribution and derivative products are not permitted.
67-
See [LICENSE](LICENSE) for full terms.
65+
Source-available. See [LICENSE](LICENSE).

0 commit comments

Comments
 (0)