PHPackages                             sweikenb/boundaries - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. sweikenb/boundaries

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

sweikenb/boundaries
===================

Project structure and sourcecode file-content checker.

v0.9.0(1y ago)02[1 PRs](https://github.com/sweikenb/boundaries/pulls)MITPHPPHP &gt;=8.2CI passing

Since Feb 4Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/sweikenb/boundaries)[ Packagist](https://packagist.org/packages/sweikenb/boundaries)[ RSS](/packages/sweikenb-boundaries/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

Boundaries
==========

[](#boundaries)

This is a plugin for the [Composer](https://getcomposer.org) package-manager.

License: **MIT**

Project status: **functional but WIP**

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

[](#installation)

```
# install composer plugin
composer require sweikenb/boundaries

# init the project configuration file
composer boundaries:init
```

**Options:**

```
# use a pre-configured symfony-template as staring point for your configuration
composer boundaries:init --template=symfony.yaml

# force override an existing configuration
composer boundaries:init --force
```

Run the check
-------------

[](#run-the-check)

You can run this command locally or in your CI/CD pipelines, based on the exit-status of the script you can identify if violations where found:

```
# User-friendly output
composer boundaries:check

# Omit output
composer boundaries:check -q
```

If any violation is found, the corresponding errors will be printed and **the script will exit with a non-zero status**.

In case of no violations, the script will print a success message and exit with a zero status.

Configuration
-------------

[](#configuration)

Boundaries will look for its configuration file `boundaries.yaml` in the composer working directory of the project.

Please refer to the template-config for further descriptions: [boundaries.yaml](templates/boundaries.yaml)

Add custom checks
-----------------

[](#add-custom-checks)

In order to add custom checks, you have to create a [composer plugin](https://getcomposer.org/doc/articles/plugins.md)and register custom checks in the plugin:

### Create your check

[](#create-your-check)

Create your own check by implementing `\Sweikenb\Library\Boundaries\Api\CheckInterface` directly or extending the abstract check (which is recommended):

```
version: 1
paths:
  src/Some/Directory:
    label: "My example directory"
    checks:
      # ...

      # Add custom check configuration that will trigger a violation in this case:
      needles:
        filename: "#(some needle)#i"
        content: "#(another needle)#i"
```

```
class MyCustomCheckForNeedles extends AbstractCheck
{
    public static function getConfigKey(): string
    {
        // This is the checks-key in the "boundaries.yaml"-file that will be active the check and contains specific
        // configurations.
        return 'needles';
    }

    public static function getPriority(): int
    {
        // In order to influence the execution order of checks, you can specify a priority here,
        // the lower the number the earlier the execution.
        return self::PRIO_DEFAULT;
    }

    public function execute(
        array $checkConfig,
        string $dir,
        string $filename,
        string &$content,
        array &$violations
    ): void {
        // Please note that the $violations and $content variables must be passed as reference!
        // While adding error-messages to the $violations is the intended way, the $content is passed by reference
        // to maintain viable performance and prevent memory issues.
        //
        // IMPORTANT: Changes to $content WILL affect other checks and should only be done intentionally!
        //
        if (isset($checkConfig['filename']) && preg_match($checkConfig['filename'], $filename)) {
            $this->addViolation($violations, $dir, $filename, sprintf('A needle was found in filename "%s"', $filename));
            break;
        }
        if (isset($checkConfig['content']) && preg_match($checkConfig['content'], $content)) {
            $this->addViolation($violations, $dir, $filename, sprintf('A needle was found in file-content "%s"', $filename));
            break;
        }
    }
}
```

### Register your checks

[](#register-your-checks)

You have to call the `\Sweikenb\Library\Boundaries\Service\CheckService::registerChecks` static method to register you checks in your plugin activation hook:

```
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\Plugin\Capable;
use Composer\Plugin\PluginInterface;
use Sweikenb\Library\Boundaries\Service\CheckService;

class MyCustomBoundariesChecksPlugin implements PluginInterface
{
    public function activate(Composer $composer, IOInterface $io): void
    {
        CheckService::registerChecks(
            new MyCustomCheckForNeedles()
        );
    }

    public function deactivate(Composer $composer, IOInterface $io): void
    {
        // nothing to do here
    }

    public function uninstall(Composer $composer, IOInterface $io): void
    {
        // nothing to do here
    }
}
```

### Troubleshoot

[](#troubleshoot)

**I want to add a custom check that validates the content of a file but `$content` is always empty**

You likely want to check contents of a file which name/filetype is not whitelisted for content loading.

Simply add your filename/-extension to the corresponding configuration of your `boundaries.yaml`:

```
# ...

content:
  only-for: "#\\.(php|twig|json|yaml|yml|xml|my-custom-filetype-to-load)$#i"

# ...
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance60

Regular maintenance activity

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

469d ago

### Community

Maintainers

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

---

Top Contributors

[![sweikenb](https://avatars.githubusercontent.com/u/366399?v=4)](https://github.com/sweikenb "sweikenb (2 commits)")

### Embed Badge

![Health badge](/badges/sweikenb-boundaries/health.svg)

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

###  Alternatives

[drupal/console-extend-plugin

Drupal Console Extend Plugin

13214.3M5](/packages/drupal-console-extend-plugin)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

96374.6k23](/packages/friendsoftypo3-content-blocks)[lullabot/drainpipe

An automated build tool to allow projects to have a set standardized operations scripts.

41716.4k2](/packages/lullabot-drainpipe)[altis/local-server

Local Server module for Altis

18208.4k2](/packages/altis-local-server)[grasmash/composerize-drupal

Convert a non-Composer managed Drupal application into a Composer-managed application.

12819.4k1](/packages/grasmash-composerize-drupal)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

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