Skip to content

Commit 2b59c05

Browse files
feat(coding-standard): Added shared configuration files under config/ for Composer-based reuse. (#1)
1 parent c3a5546 commit 2b59c05

File tree

18 files changed

+372
-434
lines changed

18 files changed

+372
-434
lines changed

.github/linters/actionlint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ paths:
44
ignore:
55
- '"pull_request" section is alias node but mapping node is expected'
66
- '"push" section is alias node but mapping node is expected'
7-
- "section is alias node but mapping node is expected"

.github/workflows/build.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/dependency-check.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/mutation.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/static.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
# Changelog
2+
3+
## 0.1.0 January 24, 2026
4+
5+
- Enh #1 Added shared configuration files under `config/` for Composer-based reuse (@terabytesoftw)

README.md

Lines changed: 131 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
11
<!-- markdownlint-disable MD041 -->
22
<p align="center">
3-
<picture>
4-
<source media="(prefers-color-scheme: dark)" srcset="https://www.yiiframework.com/image/design/logo/yii3_full_for_dark.svg">
5-
<source media="(prefers-color-scheme: light)" srcset="https://www.yiiframework.com/image/design/logo/yii3_full_for_light.svg">
6-
<img src="https://www.yiiframework.com/image/design/logo/yii3_full_for_dark.svg" alt="Yii Framework" width="80%">
7-
</picture>
8-
<h1 align="center">Template</h1>
3+
<a href="https://github.com/php-forge/coding-standard" target="_blank">
4+
<img src="https://avatars.githubusercontent.com/u/103309199?s%25253D400%252526u%25253Dca3561c692f53ed7eb290d3bb226a2828741606f%252526v%25253D4" height="150px" alt="PHP Forge">
5+
</a>
6+
<h1 align="center">Coding standard</h1>
97
<br>
108
</p>
119
<!-- markdownlint-enable MD041 -->
1210

1311
<p align="center">
14-
<a href="https://github.com/yii2-extensions/template/actions/workflows/build.yml" target="_blank">
15-
<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">
16-
</a>
17-
<a href="https://dashboard.stryker-mutator.io/reports/github.com/yii2-extensions/template/main" target="_blank">
18-
<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">
19-
</a>
20-
<a href="https://github.com/yii2-extensions/template/actions/workflows/static.yml" target="_blank">
21-
<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">
12+
<a href="https://github.com/php-forge/coding-standard/actions/workflows/linter.yml" target="_blank">
13+
<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">
2214
</a>
2315
</p>
2416

2517
<p align="center">
26-
<strong>A Yii2 extension template to create your own Yii2 extensions</strong><br>
27-
<em>PHPUnit, PHPStan, Codeception, and best practices ready out of the box</em>
18+
<strong>Centralized ECS and Rector configuration for PHP projects</strong><br>
19+
<em>Share one set of rules across multiple repositories via Composer.</em>
2820
</p>
2921

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

29+
## Installation
30+
31+
```bash
32+
composer require php-forge/coding-standard:^0.1 --dev
33+
```
34+
3735
## Quick start
3836

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

41-
```bash
42-
composer require github_username/github_repository-name
39+
- `config/ecs.php` (shared ECS rules, no paths)
40+
- `config/rector.php` (shared Rector rules, no paths)
41+
42+
Consumer repositories should create wrapper config files at the repository root.
43+
Wrappers define the paths for that repository and import the shared configuration.
44+
45+
### Generic repository
46+
47+
#### ECS (ecs.php)
48+
49+
Create `ecs.php` in your repository root:
50+
51+
```php
52+
<?php
53+
54+
declare(strict_types=1);
55+
56+
/** @var \Symplify\EasyCodingStandard\Configuration\ECSConfigBuilder $ecsConfigBuilder */
57+
$ecsConfigBuilder = require __DIR__ . '/vendor/php-forge/coding-standard/config/ecs.php';
58+
59+
return $ecsConfigBuilder->withPaths(
60+
[
61+
__DIR__ . '/src',
62+
__DIR__ . '/tests',
63+
],
64+
);
4365
```
4466

45-
### Basic Usage
67+
To override or skip rules locally, apply changes after requiring the shared config:
4668

47-
Describe how to use your extension in a basic way.
69+
```php
70+
<?php
4871

49-
## Documentation
72+
declare(strict_types=1);
5073

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

53-
- 📚 [Installation Guide](docs/installation.md)
54-
- ⚙️ [Configuration Reference](docs/configuration.md)
55-
- 💡 [Usage Examples](docs/examples.md)
56-
- 🧪 [Testing Guide](docs/testing.md)
57-
- 🛠️ [Development Guide](docs/development.md)
77+
return $ecsConfigBuilder
78+
->withPaths(
79+
[
80+
__DIR__ . '/src',
81+
__DIR__ . '/tests',
82+
],
83+
)
84+
->withSkip(
85+
[
86+
// add project-specific skips here.
87+
],
88+
);
89+
```
5890

59-
## Package information
91+
#### Rector (rector.php)
6092

61-
[![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)
62-
[![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)
63-
[![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)
64-
[![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)
65-
[![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)
93+
Create `rector.php` in your repository root:
94+
95+
```php
96+
<?php
97+
98+
declare(strict_types=1);
6699

67-
## Quality code
100+
use Rector\Config\RectorConfig;
68101

69-
[![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)
70-
[![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)
71-
[![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)
72-
[![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)
102+
return static function (RectorConfig $rectorConfig): void {
103+
$rectorConfig->import(__DIR__ . '/vendor/php-forge/coding-standard/config/rector.php');
73104

74-
## Our social networks
105+
$rectorConfig->paths(
106+
[
107+
__DIR__ . '/src',
108+
__DIR__ . '/tests',
109+
],
110+
);
75111

76-
[![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)
112+
// project-specific overrides can be added after the import.
113+
// $rectorConfig->skip([...]);
114+
};
115+
```
116+
117+
### Yii2 repositories
118+
119+
If you need framework-specific rules (Yii2), keep them in a separate config file (or a separate package)
120+
and import it after the base configuration. Do not mix Yii2-specific rules into the generic base.
121+
122+
Example (Rector):
123+
124+
```php
125+
<?php
126+
127+
declare(strict_types=1);
128+
129+
use Rector\Config\RectorConfig;
130+
131+
return static function (RectorConfig $rectorConfig): void {
132+
$rectorConfig->import(__DIR__ . '/vendor/php-forge/coding-standard/config/rector.php');
133+
$rectorConfig->import(__DIR__ . '/rector-yii2.php');
134+
135+
$rectorConfig->paths(
136+
[
137+
__DIR__ . '/src',
138+
__DIR__ . '/tests',
139+
],
140+
);
141+
};
142+
```
143+
144+
## Composer scripts
145+
146+
Follow the same convention used across PHP Forge repositories:
147+
148+
```json
149+
{
150+
"scripts": {
151+
"ecs": "./vendor/bin/ecs --fix",
152+
"rector": "./vendor/bin/rector process"
153+
}
154+
}
155+
```
156+
157+
## Documentation
158+
159+
- [Testing Guide](docs/testing.md)
160+
- [Development Guide](docs/development.md)
161+
162+
## Package information
163+
164+
[![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)
165+
[![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)
166+
[![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)
77167

78168
## License
79169

composer.json

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,41 @@
11
{
2-
"name": "yii2/template",
2+
"name": "php-forge/coding-standard",
33
"type": "library",
4-
"description": "_____",
4+
"description": "Coding standards for PHP projects.",
55
"keywords": [
6-
"_____"
6+
"coding-standard",
7+
"php",
8+
"yii2"
79
],
810
"license": "BSD-3-Clause",
911
"minimum-stability": "dev",
1012
"prefer-stable": true,
1113
"require": {
1214
"php": ">=8.1",
13-
"yiisoft/yii2": "^2.2"
14-
},
15-
"require-dev": {
16-
"infection/infection": "^0.27|^0.31",
17-
"maglnet/composer-require-checker": "^4.1",
18-
"phpstan/extension-installer": "^1.4",
19-
"phpstan/phpstan-strict-rules": "^2.0.3",
20-
"phpunit/phpunit": "^10.5",
2115
"rector/rector": "^2.1",
22-
"symplify/easy-coding-standard": "^13.0",
23-
"yii2-extensions/phpstan": "^0.3"
16+
"symplify/easy-coding-standard": "^13.0"
2417
},
2518
"autoload": {
2619
"psr-4": {
27-
"yii\\template\\": "src"
28-
}
29-
},
30-
"autoload-dev": {
31-
"psr-4": {
32-
"yii\\template\\tests\\": "tests"
20+
"PHPForge\\CodingStandard\\": "./"
3321
}
3422
},
3523
"extra": {
3624
"branch-alias": {
37-
"dev-main": "1.0.x-dev"
25+
"dev-main": "0.2.x-dev"
3826
}
3927
},
4028
"config": {
41-
"sort-packages": true,
42-
"allow-plugins": {
43-
"infection/extension-installer": true,
44-
"phpstan/extension-installer": true,
45-
"yiisoft/yii2-composer": true
46-
}
29+
"sort-packages": true
4730
},
4831
"scripts": {
49-
"check-dependencies": "./vendor/bin/composer-require-checker check",
5032
"ecs": "./vendor/bin/ecs --fix",
51-
"mutation": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100",
52-
"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'",
53-
"rector": "./vendor/bin/rector process src",
54-
"static": "./vendor/bin/phpstan --memory-limit=-1",
5533
"sync-metadata": [
5634
"curl -fsSL -o .editorconfig https://raw.githubusercontent.com/yii2-extensions/template/main/.editorconfig",
5735
"curl -fsSL -o .gitattributes https://raw.githubusercontent.com/yii2-extensions/template/main/.gitattributes",
5836
"curl -fsSL -o .gitignore https://raw.githubusercontent.com/yii2-extensions/template/main/.gitignore",
59-
"curl -fsSL -o .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml",
60-
"curl -fsSL -o ecs.php https://raw.githubusercontent.com/yii2-extensions/template/main/ecs.php",
61-
"curl -fsSL -o infection.json5 https://raw.githubusercontent.com/yii2-extensions/template/main/infection.json5",
62-
"curl -fsSL -o phpstan.neon https://raw.githubusercontent.com/yii2-extensions/template/main/phpstan.neon",
63-
"curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist",
64-
"curl -fsSL -o rector.php https://raw.githubusercontent.com/yii2-extensions/template/main/rector.php"
37+
"curl -fsSL -o .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml"
6538
],
66-
"tests": "./vendor/bin/phpunit"
39+
"rector": "./vendor/bin/rector process"
6740
}
6841
}

0 commit comments

Comments
 (0)