rmb32 / barnark-cli
The command-line delivery mechanism for Barnark — the template commands (list, scaffold, check, switch).
Requires
- php: ^8.5
- rmb32/barnark: ^2.0
- symfony/console: ^7.0
Requires (Dev)
- infection/infection: ^0.35.4
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^13.3
- rector/rector: ^2.6
- rmb32/barnark-gui: ^1.0
- squizlabs/php_codesniffer: ^4.0
Suggests
- rmb32/barnark-gui: Adds `barnark gui`, which serves the browser UI and opens it
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-07 18:34:11 UTC
README
Part of BarnSuite.
The barnark command: scaffold a project from an architecture template, check
a project against one, or switch it from one template to another. Built on
Barnark.
Requirements
- PHP 8.5+
Installation
composer global require rmb32/barnark-cli # once, for every project
# or per project
composer require --dev rmb32/barnark-cli
Usage
barnark template:list # bundled templates
barnark template:scaffold "Library" ./my-package # blank structure from a template (and tracks the folder)
barnark template:check # check every tracked folder — no arguments needed
barnark template:check ./my-package # check one tracked folder
barnark template:check "Library" ./my-package # or name the template and folder explicitly
barnark template:track "Library" ./existing-src # start tracking a folder that already exists
barnark template:untrack ./existing-src # stop tracking it
barnark template:roles ./src # which role does each folder inside play?
barnark template:roles ./src --apply # record them, so checks can see them
barnark template:exclude src/DataFixtures # leave a path out of its folder's checks and switches
barnark template:offers src/Context # what can be created in this folder?
barnark template:new Context Billing src/Context # create one, named, with its structure
barnark gui # serve the browser UI and open it (needs rmb32/barnark-gui)
barnark template:switch Library src # plan a switch, one question at a time
barnark template:switch Library src --show # what is decided, what is left
barnark template:switch Library src --apply # run the finished plan
barnark template:switch Library src --discard # throw the plan away
The project remembers which folders have which template applied in
barnark-workspace.json at the project root (the nearest parent directory that
has one, else where you run the command). template:scaffold records the folder
(--no-track opts out) and template:switch re-points it once the switch runs.
template:switch asks what to do with each piece of a tracked folder's content
— move it under a concept of the new template (keeping or changing its name),
leave it where it is, or decide later — and saves the plan after every answer in
.barnark/switch-plans/<folder>.json. Stop with q (or by ending the input)
and run the same command again to carry on; answers can also be piped in.
Nothing moves until the plan is complete and you say so, either when it offers
to apply or with --apply.
A tracked folder also records which role each thing inside it plays, and which
paths to leave alone. template:check reads both, so a real project's own
contexts and aggregates are checked where they actually are — rather than
surfacing as "Unexpected" against a bare skeleton. Name a template and a
directory explicitly and there is no workspace entry to read, so that form still
checks the skeleton only.
template:roles fills the roles in for you, off the template graph. Files need
no roles: a folder whose concept holds files accepts any .php file in it. It
also lists roles still recorded for paths that have since been deleted or
renamed, and --apply forgets them. A tracked folder nested inside another is
left to its own template's check.
The same template graph says what may be created in a folder, which is what
template:offers reports and template:new acts on:
$ barnark template:offers src/Context/Billing/Domain
----------- ----------- -------------------------------------------------------------
Concept Role key Create it with
----------- ----------- -------------------------------------------------------------
Aggregate Aggregate barnark template:new Aggregate <name> src/Context/Billing/Domain
----------- ----------- -------------------------------------------------------------
$ barnark template:new Aggregate Invoice src/Context/Billing/Domain
template:new gives the new instance whatever fixed structure its concept
carries — a Context arrives with its Domain, Application, Infrastructure
and PublicApi — and records the role it plays, so template:check stays clean
without a template:roles --apply afterwards. A concept with no children of its
own is created as a file rather than a folder: a real declaration, in the
namespace your composer.json's PSR-4 map gives that path, and an interface or an
exception where the template says so. A template can give a role another
extension, such as html.twig. Nothing already on disk is overwritten, so
re-running fills in anything missing.
A folder offers nothing when its concept takes only fixed structure (the root of
a Domain Driven Design folder is all Kernel/Transport/Context), or when
it is a leaf, or when it sits outside the template.
A path to your own template schema JSON works anywhere a template name does.
Run barnark <command> --help for every option.
| Command | Purpose |
|---|---|
template:list | List the bundled architecture templates |
template:scaffold | Build a blank directory structure from a template |
template:check | Check tracked folders (or a given directory) for consistency against a template |
template:track / template:untrack | Record / forget which template a folder has applied |
template:roles | Work out which template role each folder inside a tracked folder plays (records with --apply) |
template:offers | List the concepts a folder's template says can be created inside it |
template:new | Create one named instance of a concept the folder offers |
template:exclude | Leave a path out of its folder's checks and switches (--remove puts it back) |
template:switch | Plan a tracked folder's move to another template step by step, then run it (--show, --apply, --discard) |
Related packages
- Barnark — the core library and template catalogue.
- Barnark GUI — the same operations in a browser, across many folders.
- Barncept and Barnscaff — what the templates and scaffolding are built on.
More docs
Internals · History · Known issues
License
Proprietary. See LICENSE. Copyright (c) Roger Barnfather.