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
1 change: 0 additions & 1 deletion .github/linters/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ paths:
ignore:
- '"pull_request" section is alias node but mapping node is expected'
- '"push" section is alias node but mapping node is expected'
- "section is alias node but mapping node is expected"
22 changes: 0 additions & 22 deletions .github/workflows/build.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/dependency-check.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/mutation.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/static.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Changelog

## 0.1.0 January 24, 2026

- Enh #1 Added shared configuration files under `config/` for Composer-based reuse (@terabytesoftw)
172 changes: 131 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
<!-- 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_dark.svg" alt="Yii Framework" width="80%">
</picture>
<h1 align="center">Template</h1>
<a href="https://github.com/php-forge/coding-standard" target="_blank">
<img src="https://avatars.githubusercontent.com/u/103309199?s%25253D400%252526u%25253Dca3561c692f53ed7eb290d3bb226a2828741606f%252526v%25253D4" height="150px" alt="PHP Forge">
</a>
<h1 align="center">Coding standard</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>
<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>
<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/coding-standard/actions/workflows/linter.yml" target="_blank">
<img src="https://img.shields.io/github/actions/workflow/status/php-forge/coding-standard/linter.yml?style=for-the-badge&label=Super-Linter&logo=github" alt="Super-Linter">
</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>Centralized ECS and Rector configuration for PHP projects</strong><br>
<em>Share one set of rules across multiple repositories via Composer.</em>
</p>

## Features
Expand All @@ -34,46 +26,144 @@
<img src="./docs/svgs/features-mobile.svg" alt="Feature Overview" style="width: 100%;">
</picture>

## Installation

```bash
composer require php-forge/coding-standard:^0.1 --dev
```

## Quick start

### Installation
This package provides shared configuration files under `vendor/php-forge/coding-standard/config/`:

```bash
composer require github_username/github_repository-name
- `config/ecs.php` (shared ECS rules, no paths)
- `config/rector.php` (shared Rector rules, no paths)

Consumer repositories should create wrapper config files at the repository root.
Wrappers define the paths for that repository and import the shared configuration.

### Generic repository

#### ECS (ecs.php)

Create `ecs.php` in your repository root:

```php
<?php

declare(strict_types=1);

/** @var \Symplify\EasyCodingStandard\Configuration\ECSConfigBuilder $ecsConfigBuilder */
$ecsConfigBuilder = require __DIR__ . '/vendor/php-forge/coding-standard/config/ecs.php';

return $ecsConfigBuilder->withPaths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
);
```

### Basic Usage
To override or skip rules locally, apply changes after requiring the shared config:

Describe how to use your extension in a basic way.
```php
<?php

## Documentation
declare(strict_types=1);

For detailed configuration options and advanced usage.
/** @var \Symplify\EasyCodingStandard\Configuration\ECSConfigBuilder $ecsConfigBuilder */
$ecsConfigBuilder = require __DIR__ . '/vendor/php-forge/coding-standard/config/ecs.php';

- 📚 [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)
return $ecsConfigBuilder
->withPaths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
)
->withSkip(
[
// add project-specific skips here.
],
);
```

## Package information
#### Rector (rector.php)

[![PHP](https://img.shields.io/badge/%3E%3D8.1-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.1/en.php)
[![Yii 2.0.x](https://img.shields.io/badge/2.0.53-0073AA.svg?style=for-the-badge&logo=yii&logoColor=white)](https://github.com/yiisoft/yii2/tree/2.0.53)
[![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)
Create `rector.php` in your repository root:

```php
<?php

declare(strict_types=1);

## Quality code
use Rector\Config\RectorConfig;

[![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)
[![Super-Linter](https://img.shields.io/github/actions/workflow/status/yii2-extensions/template/linter.yml?style=for-the-badge&label=Super-Linter&logo=github)](https://github.com/yii2-extensions/template/actions/workflows/linter.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)
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->import(__DIR__ . '/vendor/php-forge/coding-standard/config/rector.php');

## Our social networks
$rectorConfig->paths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
);

[![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)
// project-specific overrides can be added after the import.
// $rectorConfig->skip([...]);
};
```

### Yii2 repositories

If you need framework-specific rules (Yii2), keep them in a separate config file (or a separate package)
and import it after the base configuration. Do not mix Yii2-specific rules into the generic base.

Example (Rector):

```php
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->import(__DIR__ . '/vendor/php-forge/coding-standard/config/rector.php');
$rectorConfig->import(__DIR__ . '/rector-yii2.php');

$rectorConfig->paths(
[
__DIR__ . '/src',
__DIR__ . '/tests',
],
);
};
```

## Composer scripts

Follow the same convention used across PHP Forge repositories:

```json
{
"scripts": {
"ecs": "./vendor/bin/ecs --fix",
"rector": "./vendor/bin/rector process"
}
}
```

## Documentation

- [Testing Guide](docs/testing.md)
- [Development Guide](docs/development.md)

## Package information

[![PHP](https://img.shields.io/badge/%3E%3D8.1-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.1/en.php)
[![Latest Stable Version](https://img.shields.io/packagist/v/php-forge/coding-standard.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/php-forge/coding-standard)
[![Total Downloads](https://img.shields.io/packagist/dt/php-forge/coding-standard.svg?style=for-the-badge&logo=composer&logoColor=white&label=Downloads)](https://packagist.org/packages/php-forge/coding-standard)

## License

Expand Down
49 changes: 11 additions & 38 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,68 +1,41 @@
{
"name": "yii2/template",
"name": "php-forge/coding-standard",
"type": "library",
"description": "_____",
"description": "Coding standards for PHP projects.",
"keywords": [
"_____"
"coding-standard",
"php",
"yii2"
],
"license": "BSD-3-Clause",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.1",
"yiisoft/yii2": "^2.2"
},
"require-dev": {
"infection/infection": "^0.27|^0.31",
"maglnet/composer-require-checker": "^4.1",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan-strict-rules": "^2.0.3",
"phpunit/phpunit": "^10.5",
"rector/rector": "^2.1",
"symplify/easy-coding-standard": "^13.0",
"yii2-extensions/phpstan": "^0.3"
"symplify/easy-coding-standard": "^13.0"
},
"autoload": {
"psr-4": {
"yii\\template\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"yii\\template\\tests\\": "tests"
"PHPForge\\CodingStandard\\": "./"
}
},
"extra": {
"branch-alias": {
"dev-main": "1.0.x-dev"
"dev-main": "0.2.x-dev"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"infection/extension-installer": true,
"phpstan/extension-installer": true,
"yiisoft/yii2-composer": true
}
"sort-packages": true
},
"scripts": {
"check-dependencies": "./vendor/bin/composer-require-checker check",
"ecs": "./vendor/bin/ecs --fix",
"mutation": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100",
"mutation-static": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan --static-analysis-tool-options='--memory-limit=-1'",
"rector": "./vendor/bin/rector process src",
"static": "./vendor/bin/phpstan --memory-limit=-1",
"sync-metadata": [
"curl -fsSL -o .editorconfig https://raw.githubusercontent.com/yii2-extensions/template/main/.editorconfig",
"curl -fsSL -o .gitattributes https://raw.githubusercontent.com/yii2-extensions/template/main/.gitattributes",
"curl -fsSL -o .gitignore https://raw.githubusercontent.com/yii2-extensions/template/main/.gitignore",
"curl -fsSL -o .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml",
"curl -fsSL -o ecs.php https://raw.githubusercontent.com/yii2-extensions/template/main/ecs.php",
"curl -fsSL -o infection.json5 https://raw.githubusercontent.com/yii2-extensions/template/main/infection.json5",
"curl -fsSL -o phpstan.neon https://raw.githubusercontent.com/yii2-extensions/template/main/phpstan.neon",
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist",
"curl -fsSL -o rector.php https://raw.githubusercontent.com/yii2-extensions/template/main/rector.php"
"curl -fsSL -o .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml"
],
"tests": "./vendor/bin/phpunit"
"rector": "./vendor/bin/rector process"
}
}
Loading