rmb32 / barn-layout
Finds a barn (the nearest .barn/barn.json) and says where each tool's files live inside it
Requires
- php: ^8.5
Requires (Dev)
- deptrac/deptrac: ^4.7
- infection/infection: ^0.35.4
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^12.0
- squizlabs/php_codesniffer: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-08 18:35:59 UTC
README
Find the barn a directory belongs to, and where each tool keeps its files inside it.
A barn is a PHP project that keeps all of its planning and architecture files in one .barn/
folder at its root, marked by .barn/barn.json:
my-shop/
.barn/
barn.json # marks the barn
barnspec.json # story-to-test settings
barnspec/ # stories and scenarios
barnark-workspace.json # tracked folders and their architecture templates
barnark/ # custom templates
switch-plans/ # architecture switches in progress
composer.json
src/
tests/
Every path stored inside those files stays relative to the barn's root (my-shop/), not to .barn/.
Requirements
- PHP 8.5+
Installation
composer require rmb32/barn-layout
Finding a barn
locate() walks up from a directory to the nearest one holding .barn/barn.json, so it works
from anywhere inside the project. It returns null outside a barn, so a tool can fall back to
its own settings:
use Rmb32\BarnLayout\Api\Factory\BarnLocatorFactory;
$barn = new BarnLocatorFactory()->create()->locate(getcwd());
$storiesFolder = $barn?->barnspecData ?? getcwd() . '/.barnspec';
The root it returns is a real path, with symlinks and .. resolved.
The layout
BarnLayout holds absolute paths for one barn:
| Property | Path |
|---|---|
root | the project root |
directory | .barn |
marker | .barn/barn.json |
barnspecConfig | .barn/barnspec.json |
barnspecData | .barn/barnspec |
barnarkWorkspace | .barn/barnark-workspace.json |
barnarkDirectory | .barn/barnark |
switchPlansDirectory | .barn/barnark/switch-plans |
Its constants (BarnLayout::MARKER, BarnLayout::BARNSPEC_DATA and so on) hold the same paths
relative to the root, for messages and for writing paths into files.
To get the layout for a root you already know, for example while creating a barn, use
BarnLayout::at(). exists() says whether its marker is there yet:
use Rmb32\BarnLayout\Api\ValueObject\BarnLayout;
$layout = BarnLayout::at('/home/sam/my-shop');
if (!$layout->exists()) {
mkdir($layout->directory);
file_put_contents($layout->marker, "{}\n");
}
Used in Barn
Barn builds and adopts barns; its tools read their files from the paths this package gives them.
Internals · History · Known issues
License
Proprietary. See LICENSE. Copyright (c) Roger Barnfather.