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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions:

jobs:
phpunit:
uses: yii2-framework/actions/.github/workflows/phpunit.yml@a28eb7d4ab03abd53ccd7c79014b3b27d09932ff # v2.0.1
uses: php-forge/actions/.github/workflows/phpunit.yml@a574dbe95fc370db1b7b5ea546cd5ff5b70304d6 # v3.0.0
with:
php-version: '["8.3","8.4","8.5"]'
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ permissions:

jobs:
composer-require-checker:
uses: yii2-framework/actions/.github/workflows/composer-require-checker.yml@a28eb7d4ab03abd53ccd7c79014b3b27d09932ff # v2.0.1
uses: php-forge/actions/.github/workflows/composer-require-checker.yml@a574dbe95fc370db1b7b5ea546cd5ff5b70304d6 # v3.0.0
2 changes: 1 addition & 1 deletion .github/workflows/ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ permissions:

jobs:
easy-coding-standard:
uses: yii2-framework/actions/.github/workflows/ecs.yml@a28eb7d4ab03abd53ccd7c79014b3b27d09932ff # v2.0.1
uses: php-forge/actions/.github/workflows/ecs.yml@a574dbe95fc370db1b7b5ea546cd5ff5b70304d6 # v3.0.0
2 changes: 1 addition & 1 deletion .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions:

jobs:
mutation:
uses: yii2-framework/actions/.github/workflows/infection.yml@a28eb7d4ab03abd53ccd7c79014b3b27d09932ff # v2.0.1
uses: php-forge/actions/.github/workflows/infection.yml@a574dbe95fc370db1b7b5ea546cd5ff5b70304d6 # v3.0.0
with:
phpstan: true
secrets:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ permissions:

jobs:
quality:
uses: yii2-framework/actions/.github/workflows/quality.yml@a28eb7d4ab03abd53ccd7c79014b3b27d09932ff # v2.0.1
uses: php-forge/actions/.github/workflows/quality.yml@a574dbe95fc370db1b7b5ea546cd5ff5b70304d6 # v3.0.0
permissions:
contents: read
with:
codespell-config: .github/linters/.codespellrc
editorconfig-checker-config: .github/linters/.editorconfig-checker.json
markdownlint-config: .github/linters/.markdown-lint.yml
prettier-config: .prettierrc.json
prettier-ignore-path: .prettierignore
yamllint-targets: .github
2 changes: 1 addition & 1 deletion .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:

jobs:
security:
uses: yii2-framework/actions/.github/workflows/security.yml@a28eb7d4ab03abd53ccd7c79014b3b27d09932ff # v2.0.1
uses: php-forge/actions/.github/workflows/security.yml@a574dbe95fc370db1b7b5ea546cd5ff5b70304d6 # v3.0.0
permissions:
contents: read
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ permissions:

jobs:
phpstan:
uses: yii2-framework/actions/.github/workflows/phpstan.yml@a28eb7d4ab03abd53ccd7c79014b3b27d09932ff # v2.0.1
uses: php-forge/actions/.github/workflows/phpstan.yml@a574dbe95fc370db1b7b5ea546cd5ff5b70304d6 # v3.0.0
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

## 0.1.0 Under development

- feat: initial development release.
194 changes: 151 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,79 +1,187 @@
<!-- markdownlint-disable MD041 -->
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://www.yiiframework.com/image/design/logo/yii3_full_for_dark.svg">
<source media="(prefers-color-scheme: light)" srcset="https://www.yiiframework.com/image/design/logo/yii3_full_for_light.svg">
<img src="https://www.yiiframework.com/image/design/logo/yii3_full_for_light.svg" alt="Yii Framework" width="80%">
</picture>
<h1 align="center">Template</h1>
<a href="https://github.com/php-forge/debug" target="_blank">
<img src="https://avatars.githubusercontent.com/u/103309199?s=400&u=ca3561c692f53ed7eb290d3bb226a2828741606f&v=4" width="30%" alt="PHP Forge">
</a>
<h1 align="center">Debug Interop</h1>
<br>
</p>
<!-- markdownlint-enable MD041 -->

<p align="center">
<a href="https://github.com/yii2-extensions/template/actions/workflows/build.yml" target="_blank">
<img src="https://img.shields.io/github/actions/workflow/status/yii2-extensions/template/build.yml?style=for-the-badge&label=PHPUnit&logo=github" alt="PHPUnit">
<a href="https://github.com/php-forge/debug/actions/workflows/build.yml" target="_blank">
<img src="https://img.shields.io/github/actions/workflow/status/php-forge/debug/build.yml?style=for-the-badge&label=PHPUnit&logo=github" alt="PHPUnit">
</a>
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii2-extensions/template/main" target="_blank">
<img src="https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyii2-extensions%2Ftemplate%2Fmain" alt="Mutation Testing">
<a href="https://dashboard.stryker-mutator.io/reports/github.com/php-forge/debug/main" target="_blank">
<img src="https://img.shields.io/endpoint?style=for-the-badge&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fphp-forge%2Fdebug%2Fmain" alt="Mutation Testing">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
<img src="https://img.shields.io/github/actions/workflow/status/yii2-extensions/template/static.yml?style=for-the-badge&label=PHPStan&logo=github" alt="PHPStan">
<a href="https://github.com/php-forge/debug/actions/workflows/static.yml" target="_blank">
<img src="https://img.shields.io/github/actions/workflow/status/php-forge/debug/static.yml?style=for-the-badge&label=PHPStan&logo=github" alt="PHPStan">
</a>
<a href="https://github.com/yii2-extensions/template/actions/workflows/security.yml" target="_blank">
<img src="https://img.shields.io/github/actions/workflow/status/yii2-extensions/template/security.yml?style=for-the-badge&label=Security&logo=github" alt="Security">
<a href="https://github.com/php-forge/debug/actions/workflows/security.yml" target="_blank">
<img src="https://img.shields.io/github/actions/workflow/status/php-forge/debug/security.yml?style=for-the-badge&label=Security&logo=github" alt="Security">
</a>
</p>

<p align="center">
<strong>A Yii2 extension template to create your own Yii2 extensions</strong><br>
<em>PHPUnit, PHPStan, Codeception, and best practices ready out of the box</em>
<strong>Framework-neutral contracts for portable collectors and panels rendered by the debugger frontend.</strong>
</p>

## Features
## A complete panel in two classes

A collector buffers diagnostics while the request runs; a panel turns the stored capture into a view. Neither
imports a debugger engine, and both share one identifier.

```php
use PHPForge\Debug\CollectorInterface;

final class CacheCollector implements CollectorInterface
{
/**
* @var list<array{string, string, string}>
*/
private array $operations = [];
private bool $started = false;

public function capture(): array|null
{
return $this->started ? ['operations' => $this->operations] : null;
}

public function id(): string
{
return 'cache';
}

public function record(string $operation, string $key, string $result): void
{
if ($this->started) {
$this->operations[] = [$operation, $key, $result];
}
}

public function shutdown(): void
{
$this->started = false;
$this->operations = [];
}

public function startup(): void
{
$this->started = true;
}
}
```

```php
use PHPForge\Debug\{ColumnStyle, Panel, PanelView};

final class CachePanel extends Panel
{
protected const string ICON = 'db';
protected const string ID = 'cache';
protected const string TITLE = 'Cache';

public function present(array $data): PanelView
{
$operations = is_array($data['operations'] ?? null) ? $data['operations'] : [];

$view = PanelView::create()
->summary(count($operations) === 1 ? ' operation' : ' operations', count($operations))
->toolbar('Cache', count($operations))
->active($operations !== []);

return $operations === []
? $view->emptyState('No cache operations', 'The cache was observed, but nothing happened.')
: $view->table(
['Operation', 'Key', 'Result'],
$operations,
collapsible: true,
styles: [1 => ColumnStyle::IDENTIFIER],
);
}
}
```

Call `record()` from the application service that already knows about the operation. `capture()` returns `null` when
there is nothing to report, and an array otherwise: an empty array is an observed empty request, not absence. The
host encodes that array strictly, so omit secrets and keep values JSON-encodable.

<picture>
<source media="(min-width: 768px)" srcset="./docs/svgs/features.svg">
<img src="./docs/svgs/features-mobile.svg" alt="Feature Overview" style="width: 100%;">
</picture>
## Register it

## Quick start
Merge these fragments into an application whose debugger is already enabled. The collector's `id()` and the panel's
`ID` must match: that is how the host pairs a capture with its panel.

### Installation
```php
// Yii2: inside the YII_ENV_DEV guard, preserving the existing module settings.
$collector = new CacheCollector();

```bash
composer require github_username/github_repository-name
$config['modules']['debug']['collectors'][] = $collector;
$config['modules']['debug']['panels'][] = new CachePanel();
```

### Basic Usage
```php
// Yii3: return the extended registry from the application's development DI factory.
$collector = new CacheCollector();

$registry = $registry
->withCollector($collector)
->withPanel(new CachePanel());
```

Describe how to use your extension in a basic way.
Both hosts derive the IDs and wrap the portable objects internally. No catalog entry, icon enum, storage dispatch
entry, or change to an official package is needed. Inject the same `$collector` into the application service that
calls `record()`.

A runnable version of this example, capturing through PSR-3 instead of a direct call, lives in
[tests/Support](tests/Support); `python3 tools/check-consumer.py` installs it as an independent Composer package and
replays a stored capture with no debugger host present.

## Presentation vocabulary

Five types are published: `CollectorInterface`, `Panel`, `PanelView`, `Tone`, and `ColumnStyle`. Everything a panel can
display is a `PanelView` method, so there is no value class to import and no shape to build by hand.

```php
use PHPForge\Debug\{ColumnStyle, PanelView, Tone};

PanelView::create()
->summary(' props', 2)
->toolbar('Props', 2)
->heading('Props', section: true)
->overview(['Component' => 'Site', 'State' => PanelView::badge('shared', Tone::INFO)])
->paragraph('Rendered by ', PanelView::code('Inertia::render()'))
->callout(Tone::WARNING, 'Runtime inspection is unavailable.')
->table(['Prop', 'Value'], [['auth', PanelView::value(['id' => 1])]], styles: [0 => ColumnStyle::IDENTIFIER])
->group('Component', PanelView::create()->paragraph('Nested content'))
->emptyState('No operations', 'The cache was observed, but nothing happened.')
->disclosure('Raw payload', $json)
->active(true);
```

## Documentation
Plain scalars and `null` become text. `PanelView::text()`, `::strong()`, `::code()`, `::preview()`, `::badge()`, and
`::value()` produce validated inline values accepted wherever a scalar is accepted. Every method validates its
arguments and rejects invalid input with an explicit `InvalidArgumentException`. The host reads the finished
description through `summaryMetrics()`, `toolbarMetrics()`, `blocks()`, and `isActive()`.

For detailed configuration options and advanced usage.
## Verification

- 📚 [Installation Guide](docs/installation.md)
- ⚙️ [Configuration Reference](docs/configuration.md)
- 💡 [Usage Examples](docs/examples.md)
- 🧪 [Testing Guide](docs/testing.md)
- 🛠️ [Development Guide](docs/development.md)
[docs/testing.md](docs/testing.md) lists the Composer scripts and the two isolated-consumer checks.

## Package information

[![PHP](https://img.shields.io/badge/%3E%3D8.3-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.3/en.php)
[![Yii 22.0.x](https://img.shields.io/badge/22.0.x-0073AA.svg?style=for-the-badge&logo=yii&logoColor=white)](https://github.com/yiisoft/yii2/tree/22.0)
[![Latest Stable Version](https://img.shields.io/packagist/v/yii2-extensions/template.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/yii2-extensions/template)
[![Total Downloads](https://img.shields.io/packagist/dt/yii2-extensions/template.svg?style=for-the-badge&logo=composer&logoColor=white&label=Downloads)](https://packagist.org/packages/yii2-extensions/template)
[![PHPStan Level Max](https://img.shields.io/badge/PHPStan-Level%20Max-4F5D95.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/php-forge/debug/actions/workflows/static.yml)
[![Latest Stable Version](https://img.shields.io/packagist/v/php-forge/debug.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/php-forge/debug)
[![Total Downloads](https://img.shields.io/packagist/dt/php-forge/debug.svg?style=for-the-badge&logo=composer&logoColor=white&label=Downloads)](https://packagist.org/packages/php-forge/debug)

## Project status
## Code quality

[![Codecov](https://img.shields.io/codecov/c/github/yii2-extensions/template.svg?style=for-the-badge&logo=codecov&logoColor=white&label=Coverage)](https://codecov.io/github/yii2-extensions/template)
[![PHPStan Level Max](https://img.shields.io/badge/PHPStan-Level%20Max-4F5D95.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/yii2-extensions/template/actions/workflows/static.yml)
[![Quality](https://img.shields.io/github/actions/workflow/status/yii2-extensions/template/quality.yml?style=for-the-badge&label=Quality&logo=github)](https://github.com/yii2-extensions/template/actions/workflows/quality.yml)
[![StyleCI](https://img.shields.io/badge/StyleCI-Passed-44CC11.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.styleci.io/repos/698621511?branch=main)
[![Codecov](https://img.shields.io/codecov/c/github/php-forge/debug.svg?style=for-the-badge&logo=codecov&logoColor=white&label=Coverage)](https://codecov.io/gh/php-forge/debug)
[![Quality](https://img.shields.io/github/actions/workflow/status/php-forge/debug/quality.yml?style=for-the-badge&label=Quality&logo=github)](https://github.com/php-forge/debug/actions/workflows/quality.yml)
[![StyleCI](https://img.shields.io/badge/StyleCI-Passed-44CC11.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.styleci.io/repos/php-forge/debug?branch=main)

## Our social networks
## Social networks

[![Follow on X](https://img.shields.io/badge/-Follow%20on%20X-1DA1F2.svg?style=for-the-badge&logo=x&logoColor=white&labelColor=000000)](https://x.com/Terabytesoftw)

Expand Down
12 changes: 12 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
coverage:
precision: 2
round: down
status:
project:
default:
target: 100%
threshold: 0%
patch:
default:
target: 100%
threshold: 0%
23 changes: 12 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"name": "yii2-extensions/template",
"name": "php-forge/debug",
"type": "library",
"description": "_____",
"description": "Framework-neutral contracts and declarative presentation models for debugger extensions.",
"keywords": [
"_____"
"debug",
"interop",
"panel"
],
"license": "BSD-3-Clause",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.3",
"yiisoft/yii2": "^22"
"php": ">=8.3"
},
"require-dev": {
"infection/infection": "^0.35",
Expand All @@ -20,29 +21,29 @@
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-strict-rules": "^2.0.3",
"phpunit/phpunit": "^12.5",
"yii2-extensions/phpstan": "^0.4"
"psr/log": "^3.0",
"phpstan/phpstan": "^2.2"
},
"autoload": {
"psr-4": {
"yii\\template\\": "src"
"PHPForge\\Debug\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"yii\\template\\tests\\": "tests"
"PHPForge\\Debug\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
"dev-main": "0.1.x-dev"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true,
"phpstan/extension-installer": true,
"yiisoft/yii2-composer": true
"phpstan/extension-installer": true
}
},
"scripts": {
Expand Down
10 changes: 0 additions & 10 deletions docs/configuration.md

This file was deleted.

Loading
Loading