PHPackages                             valkyrja/phparkitect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. valkyrja/phparkitect

ActiveProject[DevOps &amp; Deployment](/categories/devops)

valkyrja/phparkitect
====================

PHPArkitect for the Valkyrja Project.

v26.2.2(1mo ago)01.8k↓17.1%MITPHPPHP &gt;=8.4CI passing

Since Apr 15Pushed 1w agoCompare

[ Source](https://github.com/valkyrjaio/ci-phparkitect-php)[ Packagist](https://packagist.org/packages/valkyrja/phparkitect)[ Docs](https://www.valkyrja.io/)[ RSS](/packages/valkyrja-phparkitect/feed)WikiDiscussions 26.x Synced 1w ago

READMEChangelog (8)Dependencies (1)Versions (20)Used By (0)

[ ![](https://raw.githubusercontent.com/valkyrjaio/art/refs/heads/master/long-banner/orange/php.png)](https://valkyrja.io)

Valkyrja PHPArkitect
====================

[](#valkyrja-phparkitect)

Shared PHPArkitect configuration for Valkyrja PHP projects — architectural rules that encode the naming and namespace conventions used across the Valkyrja project, plus custom expressions that fill gaps in the built-in PHPArkitect expression library.

 [![PHP Version Require](https://camo.githubusercontent.com/e01181fc7807ab486adead9f1ff884d0668cd97f0e82c0216f247d1aa57795a4/68747470733a2f2f706f7365722e707567782e6f72672f76616c6b79726a612f70687061726b69746563742f726571756972652f706870)](https://packagist.org/packages/valkyrja/phparkitect) [![Latest Stable Version](https://camo.githubusercontent.com/eafcbfe295d380ab95bbaa6f9e758bf32fee48bd0cee152c130795b53f828510/68747470733a2f2f706f7365722e707567782e6f72672f76616c6b79726a612f70687061726b69746563742f76)](https://packagist.org/packages/valkyrja/phparkitect) [![License](https://camo.githubusercontent.com/6c7e03d231f13ed7b804b1e5adc50de2b0495d05e7d2d9e1fd9a3c80cbaf1239/68747470733a2f2f706f7365722e707567782e6f72672f76616c6b79726a612f70687061726b69746563742f6c6963656e7365)](https://packagist.org/packages/valkyrja/phparkitect) [![CI Status](https://github.com/valkyrjaio/ci-phparkitect-php/actions/workflows/ci.yml/badge.svg?branch=26.x)](https://github.com/valkyrjaio/ci-phparkitect-php/actions/workflows/ci.yml?query=branch%3A26.x) [![Scrutinizer](https://camo.githubusercontent.com/7e30d302483954bedda83519a2fcad5c94c162b659804c4c78b154e0ee18982c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f76616c6b79726a61696f2f63692d70687061726b69746563742d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d32362e78)](https://scrutinizer-ci.com/g/valkyrjaio/ci-phparkitect-php/?branch=26.x) [![Coverage Status](https://camo.githubusercontent.com/502914c2fb2971f6104a3682b97a70d48b4a1887fa14066a78a36efcfcc4be3d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f76616c6b79726a61696f2f63692d70687061726b69746563742d7068702f62616467652e7376673f6272616e63683d32362e78)](https://coveralls.io/github/valkyrjaio/ci-phparkitect-php?branch=26.x) [![Psalm Shepherd](https://camo.githubusercontent.com/8807f9e328b22a54aa0f0d006277edf501513f22aa0804826a74955181af9a50/68747470733a2f2f73686570686572642e6465762f6769746875622f76616c6b79726a61696f2f63692d70687061726b69746563742d7068702f636f7665726167652e737667)](https://shepherd.dev/github/valkyrjaio/ci-phparkitect-php) [![Maintainability Rating](https://camo.githubusercontent.com/b8c7176fcca7073655361af4534adca09bb6e6bf8458c1e5bd90d8749267d9ce/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d76616c6b79726a61696f5f70687061726b6974656374266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/summary/new_code?id=valkyrjaio_phparkitect)

Overview
--------

[](#overview)

This repository contains two things:

1. **`Valkyrja\Arkitect\Rules`** — a reusable rule set that encodes the naming and namespace conventions used across the Valkyrja project. Drop it into any PHPArkitect config to enforce those conventions on your own code.
2. **Custom expressions** — PHPArkitect `Expression` implementations that fill gaps in the built-in expression library.

Installation
------------

[](#installation)

```
composer require valkyrja/phparkitect

```

Usage
-----

[](#usage)

Reference `Rules::getRules()` from your `phparkitect.php` configuration file:

```
// phparkitect.php
use Valkyrja\Arkitect\Rules;

return Rules::getRules();

```

`getRules()` returns a closure that receives a PHPArkitect `Config` object and registers all rules against two class sets:

- `src/` — source rules (naming, namespaces, architectural constraints)
- `tests/` — test rules (finality, naming conventions for test helpers)

The paths are resolved relative to the directory **three levels above**`src/Arkitect/Rules.php` (i.e. the project root), matching the standard Valkyrja monorepo layout.

Run PHPArkitect as normal:

```
vendor/bin/phparkitect check

```

Rules Reference
---------------

[](#rules-reference)

### Source Rules

[](#source-rules)

#### No `@author` docblocks

[](#no-author-docblocks)

All classes must not contain an `@author` docblock annotation.

#### Attributes

[](#attributes)

RuleConstraintClasses with `#[Attribute]` must reside in `*Attribute\` namespacesAttributes belong in dedicated namespacesClasses in `*Attribute\` namespaces must carry `#[Attribute]`Only attributes live in attribute namespacesClasses outside `*Attribute\*` must not carry `#[Attribute]`Non-attributes must not be attributed#### Constants

[](#constants)

RuleConstraintFinal classes (excluding `*Security` and `*Provider`) must reside in `*Constant\`Constants namespaceClasses in `*Constant\` must be finalConstants are sealed#### Providers

[](#providers)

TypeNamingNamespace`ServiceProviderContract``*ServiceProvider``*Provider\``ComponentProviderContract``*ComponentProvider``*Provider\``CliRouteProviderContract``*RouteProvider``*Provider\``ListenerProviderContract``*ListenerProvider``*Provider\``HttpRouteProviderContract``*RouteProvider``*Provider\`All classes in `*Provider\``*Provider` suffix—#### Factories

[](#factories)

RuleConstraintClasses named `*Factory` must reside in `*Factory\`Factories belong in factory namespacesClasses in `*Factory\` must be named `*Factory`Only factories live in factory namespaces#### CLI Commands

[](#cli-commands)

Classes named `*Command` (outside `Valkyrja\Cli\*`, and not `*Handler` or `*Middleware`) must reside in `*Cli\Command\` namespaces.

#### Security

[](#security)

Classes named `*Security` must reside in `*Security\` namespaces and must be final.

#### Exceptions and Throwables

[](#exceptions-and-throwables)

RuleConstraintClasses named `*Exception` must reside in `*Exception\`Exceptions namespaceClasses extending `Throwable` must reside in `*Throwable\`Throwable objects belong in throwable namespacesClasses implementing `Throwable` must be named `*Exception`Throwables are exceptionsClasses named `*RuntimeException` must reside in `*Abstract\` and be abstractBase runtime exceptions are abstractClasses named `*InvalidArgumentException` must reside in `*Abstract\` and be abstractBase invalid argument exceptions are abstract#### Types, Models, and Entities

[](#types-models-and-entities)

RuleConstraintClasses extending `Type` (outside Config, Entity, Model namespaces) must reside in `*Type\`Types namespaceClasses extending `Model` (outside Config, Entity namespaces) must reside in `*Model\`Models namespaceClasses extending `Entity` must reside in `*Entity\`Entities namespace#### Interfaces (Contracts)

[](#interfaces-contracts)

RuleConstraintInterfaces must reside in `*Contract\` namespacesContracts namespaceClasses in `*Contract\` must be interfacesOnly interfaces are contractsInterfaces (except `*Throwable`) must be named `*Contract`Contract naming conventionClasses named `*Contract` must be interfacesNaming implies interface#### Traits

[](#traits)

RuleConstraintTraits must reside in `*Trait\` namespacesTraits namespaceClasses in `*Trait\` must be traitsOnly traits live in trait namespacesTraits must not be named `*Trait*`No "Trait" in the nameAll classes must not be named `*Trait*`No "Trait" in any name#### Abstract Classes

[](#abstract-classes)

RuleConstraintAbstract classes (outside `*Factory` and specific routing controller namespaces) must reside in `*Abstract\`Abstract namespaceClasses in `*Abstract\` must be abstractOnly abstract classes live thereAbstract classes must not be named `*Abstract*`No "Abstract" in the nameNon-abstract classes must not be named `*Abstract*`No "Abstract" in any name#### Enums

[](#enums)

RuleConstraintEnums must reside in `*Enum\` namespacesEnums namespaceClasses in `*Enum\` (outside `Valkyrja\Type\Enum`) must be enumsOnly enums live in enum namespacesEnums must not be named `*Enum*`No "Enum" in enum namesNon-enums (outside `Valkyrja\Type\Enum`, excluding `EnhancedEnumSupport`) must not be named `*Enum*`No "Enum" in non-enum names### Test Rules

[](#test-rules)

RuleConstraintAll classes must not contain `@author` docblocksSame as srcTest classes (in `*Tests\`, not `*TestCase`, `*AttributeClass`, `*EnvClass`, non-abstract, non-trait, outside `Vendor`) must be finalTests are sealedClasses in `*Classes\` (non-enum, non-trait) must be named `*Class`Test helper class namingClasses in `*Classes\` must not be named `*Test`Test helpers are not testsClasses not named `*Test` must not reside in `*Unit\` or `*Functional\`Only tests live in test namespacesTraits (not `TestCase`) in tests must reside in `*Trait\` and be named `*Trait`Test trait conventionsCustom Expressions
------------------

[](#custom-expressions)

### `NotHaveAttribute`

[](#nothaveattribute)

`Valkyrja\Arkitect\Expression\ForClasses\NotHaveAttribute`

The inverse of PHPArkitect's built-in `HaveAttribute`. Evaluates to a violation when the target class **does** carry the specified PHP attribute.

```
use Valkyrja\Arkitect\Expression\ForClasses\NotHaveAttribute;

Rule::allClasses()
    ->that(new NotResideInTheseNamespaces('*Attribute\\*'))
    ->should(new NotHaveAttribute(Attribute::class))
    ->because('Non-attribute classes must not carry #[Attribute]');

```

**Constructor:**

```
new NotHaveAttribute(string $attribute)

```

ParameterDescription`$attribute`Fully qualified class name of the PHP attribute to check**Violation message format:**

```
 should not have the attribute  because

```

Workflows
---------

[](#workflows)

The [`_workflow-call.yml`](.github/workflows/_workflow-call.yml) reusable workflow runs PHPArkitect against the calling repository's source. It is designed to be called from other repositories via `workflow_call`.

### Inputs

[](#inputs)

InputTypeDefaultDescription`paths`string—**Required.** YAML filter spec with two keys: `ci` (CI config files that trigger a base-branch fetch) and `files` (all files that trigger the check).`post-pr-comment`boolean`true`Post a PR comment on failure and remove it on success. Disable when the calling workflow handles its own reporting.`composer-options`string`''`Extra flags passed to every `composer install` step (e.g. `--ignore-platform-req=ext-openswoole`).`php-version`string`'8.4'`PHP version to use.`ci-directory`string`'.github/ci/phparkitect'`Path to the CI directory containing `composer.json` and the tool config.`extensions`string`'mbstring, intl'`PHP extensions to install via `shivammathur/setup-php`.### Usage

[](#usage-1)

```
jobs:
  phparkitect:
    uses: valkyrjaio/ci-phparkitect-php/.github/workflows/_workflow-call.yml@26.x
    permissions:
      pull-requests: write
      contents: read
    with:
      php-version: '8.4'
      paths: |
        ci:
          - '.github/ci/phparkitect/**'
          - '.github/workflows/phparkitect.yml'
        files:
          - '.github/ci/phparkitect/**'
          - '.github/workflows/phparkitect.yml'
          - 'src/**/*.php'
          - 'composer.json'
    secrets: inherit
```

`secrets: inherit` is required to pass the `VALKYRJA_GHA_APP_ID` and `VALKYRJA_GHA_PRIVATE_KEY` org secrets used for PR comments.

Contributing
------------

[](#contributing)

See [`CONTRIBUTING.md`](https://github.com/valkyrjaio/.github/blob/master/CONTRIBUTING.md) for the submission process and [`VOCABULARY.md`](https://github.com/valkyrjaio/.github/blob/master/VOCABULARY.md) for the terminology used across Valkyrja.

Security Issues
---------------

[](#security-issues)

If you discover a security vulnerability, please follow our [disclosure procedure](https://github.com/valkyrjaio/.github/blob/master/SECURITY.md).

License
-------

[](#license)

Licensed under the [MIT license](https://opensource.org/licenses/MIT). See [`LICENSE.md`](./LICENSE.md).

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance95

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 54.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Recently: every ~11 days

Total

9

Last Release

8d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fbb43a59fb790365b014e53f82e3f26893867e4a47a249fc92962b6dc76878f2?d=identicon)[MelechMizrachi](/maintainers/MelechMizrachi)

---

Top Contributors

[![MelechMizrachi](https://avatars.githubusercontent.com/u/1179171?v=4)](https://github.com/MelechMizrachi "MelechMizrachi (59 commits)")[![valkyrja-volundr[bot]](https://avatars.githubusercontent.com/in/2462900?v=4)](https://github.com/valkyrja-volundr[bot] "valkyrja-volundr[bot] (49 commits)")

---

Tags

civalkyrjaphparkitect

### Embed Badge

![Health badge](/badges/valkyrja-phparkitect/health.svg)

```
[![Health](https://phpackages.com/badges/valkyrja-phparkitect/health.svg)](https://phpackages.com/packages/valkyrja-phparkitect)
```

###  Alternatives

[saggre/phpdocumentor-markdown

Markdown template for phpDocumentor3

2293.1k41](/packages/saggre-phpdocumentor-markdown)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
