Skip to content

Commit 5814c3e

Browse files
authored
Add ADR records (#83)
* Document some architectural decisions for the project.
1 parent 684c6c4 commit 5814c3e

File tree

6 files changed

+179
-0
lines changed

6 files changed

+179
-0
lines changed

docs/decisions/01-follow-psr-11.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
status: accepted
3+
date: 14-JAN-2026
4+
---
5+
6+
# Follow PSR-11 for Dependency Injection Containers
7+
8+
## Context and Problem Statement
9+
10+
The spacetraders application should use a dependency injection container (DIC) to promote object composition and discourage direct instantiation of service classes.
11+
12+
## Considered Options
13+
14+
* [Adopting PSR-11](https://www.php-fig.org/psr/psr-11/)
15+
* Rolling a custom container
16+
17+
## Decision Outcome
18+
19+
Any DIC we use must follow PSR-11 to allow us to change to a new or better implementation in the future.
20+
21+
### Consequences
22+
23+
* May limit the packages we can use as a DIC
24+
* We are not locked into using any single solution.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
status: accepted
3+
date: 14-JAN-2026
4+
---
5+
6+
# Use PHP-DI for service container
7+
8+
## Context and Problem Statement
9+
10+
PHP classes should support dependency injection for composing objects instead of direct instantiation. We need to provide an easy-to-use Dependency Injection container for developers that follows PSR-11 container interface.
11+
12+
## Considered Options
13+
14+
* php-di/php-di
15+
* PRO: autowiring based on typehints, can register with callbacks. Have previous experience using it.
16+
* CON: many open issues
17+
* league/container
18+
* PRO: actively maintained
19+
* CON: service registration is verbose
20+
* symfony/dependency-injection
21+
* PRO: backed by symfony development
22+
* CON: service registration is verbose
23+
24+
## Decision Outcome
25+
26+
Use PHP-DI due to familiarity with it and its syntax.
27+
28+
### Consequences
29+
30+
* Will implement a service container that uses PHP-DI
31+
* May need to look into container compilation as application grows.
32+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
status: accepted
3+
date: 01-Jan-2026
4+
---
5+
6+
7+
# Use PSR-4 for Autoloading custom classes
8+
9+
## Context and Problem Statement
10+
11+
Project needs to follow some autoloading mechanism for PHP classes.
12+
13+
## Considered Options
14+
15+
* Adopt [PSR-4](https://www.php-fig.org/psr/psr-4/)
16+
* PRO: supported by Composer and known wider PHP community
17+
* Write a custom autoloader
18+
* CON: another thing to maintain
19+
20+
## Decision Outcome
21+
22+
Custom classes must follow PSR-4 conventions for naming files and namespaces.
23+
24+
### Consequences
25+
26+
We will need to register namespaces in `composer.json`. For example:
27+
28+
```json
29+
"autoload": {
30+
"psr-4": {
31+
"Phparch\\SpaceTradersCLI\\": "cli/",
32+
"Phparch\\SpaceTraders\\": "src/"
33+
}
34+
},
35+
```
36+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
status: accepted
3+
date: 01-JAN-2026
4+
---
5+
6+
# Adopts PER-3 as project coding style
7+
8+
## Context and Problem Statement
9+
10+
Spacetraders application code needs to follow a consistent coding style guide that can be enforced with an automatic linter and supported by most IDEs.
11+
12+
## Considered Options
13+
14+
Both of these candidates report violations and can try to fix them.
15+
16+
* [PSR-12](https://www.php-fig.org/psr/psr-12/)
17+
* * PRO: existing coding standard we can adopt
18+
* CON: superceded by PER-3
19+
* [PER-3](https://www.php-fig.org/per/coding-style/)
20+
* PRO: evolving standard, adopted in wider PHP community
21+
* Symfony, Drupal, WordPress or other coding standard
22+
* PRO: existing coding standard we can adopt
23+
* CON: We are not any of those projects and they each have their own quirks.
24+
25+
## Decision Outcome
26+
27+
Use PER-3 as the project's coding style and enforce it automatically.
28+
29+
### Consequences
30+
31+
Need to identify tooling for linting and automated checks.
32+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
status: accepted
3+
date: 01-JAN-2026
4+
---
5+
6+
# Use PHPCodeSniffer to enforce PER-3
7+
8+
## Context and Problem Statement
9+
10+
We have adopted [PER-3](https://www.php-fig.org/per/coding-style/) as our coding style and need automated tools to check, fix, and enforce adherence.
11+
12+
## Considered Options
13+
14+
* [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer)
15+
* PRO: Familiar with configuring it
16+
* CON: XML for rules configuration
17+
* [PHP CS Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer)
18+
* PRO: Part of symfony
19+
20+
21+
## Decision Outcome
22+
23+
Use PHP_Codesniffer since we are familiar with configuring it.
24+
25+
### Consequences
26+
27+
* Add to dev packages in `composer.json`
28+
* Document how to run its linter and fixer at the command line
29+
* Report violations when someone tries to push code.
30+
* Check for violations in CI.

docs/decisions/_adr-template.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
status: proposed | rejected | accepted | deprecated | … | superseded by ADR-0123
3+
date: DD-MMM-YYYY
4+
decision-makers:
5+
consulted:
6+
informed:
7+
---
8+
9+
10+
# <!-- short title, representative of solved problem and found solution -->
11+
12+
## Context and Problem Statement
13+
14+
15+
16+
## Considered Options
17+
18+
19+
20+
## Decision Outcome
21+
22+
23+
24+
### Consequences
25+

0 commit comments

Comments
 (0)