PHPackages                             tdwesten/statamic-builder - 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. tdwesten/statamic-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tdwesten/statamic-builder
=========================

A fluent blueprint and fieldset builder for Statamic.

v3.0.0(2mo ago)3610.3k↓47.8%14[2 PRs](https://github.com/tdwesten/statamic-builder/pulls)1MITPHPPHP ^8.3CI passing

Since Feb 12Pushed 2mo ago3 watchersCompare

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

READMEChangelog (10)Dependencies (9)Versions (33)Used By (1)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ff41a7c13f12a14013af9fe693063b00a4a60c8cc32a2f8026930d3d91bfeaa5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746477657374656e2f73746174616d69632d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tdwesten/statamic-builder)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ffc8409995fc6d0ae58ec54e389d007461bdca3351a2d425d7dddd87bead0e0f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746477657374656e2f73746174616d69632d6275696c6465722f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/tdwesten/statamic-builder/actions/workflows/tests.yml)[![Total Downloads](https://camo.githubusercontent.com/bf8754be0e69edb23057fd944e6b78d429cbbbc864c562dbc5a57f7a6e2c7385/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746477657374656e2f73746174616d69632d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tdwesten/statamic-builder)

[![Github](https://private-user-images.githubusercontent.com/224501/317867721-fb3da5da-6035-4ca4-9d70-3509c8b626c6.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzIxMzgwMjAsIm5iZiI6MTc3MjEzNzcyMCwicGF0aCI6Ii8yMjQ1MDEvMzE3ODY3NzIxLWZiM2RhNWRhLTYwMzUtNGNhNC05ZDcwLTM1MDljOGI2MjZjNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMjI2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDIyNlQyMDI4NDBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kZTRlMjM2OWRhMGY0YzQ0ODVlYjYyMWIxZjQyZDk3MjFmNDU2MDZmNGFlNzA4MWQ2MzcwMTcwZDBiOTgxNzQxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.yk7yNZzn17VPwAHp2bjCen-Yked6xN_vMTFOgKN0Cvs)](https://private-user-images.githubusercontent.com/224501/317867721-fb3da5da-6035-4ca4-9d70-3509c8b626c6.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzIxMzgwMjAsIm5iZiI6MTc3MjEzNzcyMCwicGF0aCI6Ii8yMjQ1MDEvMzE3ODY3NzIxLWZiM2RhNWRhLTYwMzUtNGNhNC05ZDcwLTM1MDljOGI2MjZjNi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMjI2JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDIyNlQyMDI4NDBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kZTRlMjM2OWRhMGY0YzQ0ODVlYjYyMWIxZjQyZDk3MjFmNDU2MDZmNGFlNzA4MWQ2MzcwMTcwZDBiOTgxNzQxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.yk7yNZzn17VPwAHp2bjCen-Yked6xN_vMTFOgKN0Cvs)

Statamic Builder
================

[](#statamic-builder)

The Statamic Builder speeds up building Statamic sites. It offers a clear method to define sites, blueprints, fieldsets, collections, navigations and taxonomies using PHP classes. This approach enhances code readability and maintainability compared to writing YAML files.

Features
--------

[](#features)

- **Fluent API**: Define Statamic components using a clean, chainable PHP API.
- **Auto-discovery**: Automatically discover and register your components from the filesystem.
- **Navigation Support**: Easily define and manage Statamic Navigations in PHP.
- **Global Sets &amp; Taxonomies**: Full support for Global Sets and Taxonomies.
- **Multi-site Support**: Define and manage multiple sites through PHP classes.
- **Artisan Commands**: Generate blueprints, fieldsets, collections, and more with dedicated commands.
- **YAML Export**: Export your PHP-defined components to standard Statamic YAML files.
- **Eloquent Support**: Full support for Statamic Eloquent Driver for Global Sets, Navigations and Collections (mount).

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

[](#installation)

You can install this addon with composer:

```
composer require tdwesten/statamic-builder
```

Requirements
------------

[](#requirements)

- PHP 8.3+
- Statamic 6.0+
- Laravel 12

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

[](#configuration)

You can publish the configuration file using:

```
php artisan vendor:publish --tag=statamic
```

The configuration file allows you to manually register components or enable auto-discovery.

### Options

[](#options)

OptionDescription`blueprints`Manual registration of blueprints, grouped by namespace.`fieldsets`Manual registration of fieldsets.`collections`Manual registration of collections.`taxonomies`Manual registration of taxonomies.`globals`Manual registration of global sets.`sites`Manual registration of sites.`navigations`Manual registration of navigations.`asset_containers`Manual registration of asset containers.`auto_registration`Enable or disable auto-discovery of components.`auto_discovery`Define custom paths for auto-discovery of each component type.Auto Registration &amp; Discovery
---------------------------------

[](#auto-registration--discovery)

Enable `auto_registration` in `config/statamic/builder.php` to automatically find components in your `app/` directory.

```
'auto_registration' => true,
```

### Discovery Requirements

[](#discovery-requirements)

For components to be auto-discovered, they must implement certain static methods:

- **Blueprints**: Must implement `static function handle()` and `static function blueprintNamespace()`.
- **Collections, Taxonomies, Globals, Navigations, Asset Containers**: Must implement `static function handle()`.
- **Sites**: Must implement `function handle()`.

Blueprints and Fieldsets
------------------------

[](#blueprints-and-fieldsets)

### Creating a Blueprint

[](#creating-a-blueprint)

1. Generate a blueprint: ```
    php artisan make:blueprint PageBlueprint
    ```
2. Define your fields in the `registerTabs` method:

```
namespace App\Blueprints;

use Tdwesten\StatamicBuilder\Blueprint;
use Tdwesten\StatamicBuilder\FieldTypes\Section;
use Tdwesten\StatamicBuilder\FieldTypes\Text;
use Tdwesten\StatamicBuilder\FieldTypes\Tab;

class PageBlueprint extends Blueprint
{
    public static function handle(): string
    {
        return 'page';
    }

    public static function blueprintNamespace(): string
    {
        return 'collections.pages';
    }

    public function registerTabs(): array
    {
        return [
            Tab::make('General', [
                Section::make('General', [
                    Text::make('title')
                        ->displayName('Title')
                        ->instructions('The title of the page')
                        ->localizable()
                        ->required()
                ]),
            ]),
        ];
    }
}
```

### Creating a Fieldset

[](#creating-a-fieldset)

1. Generate a fieldset: ```
    php artisan make:fieldset HeroFieldset
    ```
2. Define fields:

```
namespace App\Fieldsets;

use Tdwesten\StatamicBuilder\Fieldset;
use Tdwesten\StatamicBuilder\FieldTypes\Assets;
use Tdwesten\StatamicBuilder\FieldTypes\Text;

class HeroFieldset extends Fieldset
{
    public function registerFields(): array
    {
        return [
            Text::make('title')->displayName('Title')->required(),
            Assets::make('image')->displayName('Image')->maxItems(1),
        ];
    }
}
```

Collections, Taxonomies, and Globals
------------------------------------

[](#collections-taxonomies-and-globals)

### Collections

[](#collections)

Generate a collection:

```
php artisan make:collection Articles
```

```
namespace App\Collections;

use Tdwesten\StatamicBuilder\BaseCollection;

class Articles extends BaseCollection
{
    public static function handle(): string
    {
        return 'articles';
    }

    public function title(): string
    {
        return 'Articles';
    }
}
```

Most methods in `BaseCollection` now have default implementations, so you only need to override what you want to change (e.g., `route()`, `sites()`, `template()`).

### Taxonomies

[](#taxonomies)

Generate a taxonomy:

```
php artisan make:taxonomy Categories
```

### Global Sets

[](#global-sets)

Global sets can be defined as PHP classes. This allows you to manage global variables and their localization through PHP classes.

1. Generate a global set:

    ```
    php artisan make:global-set SiteSettings
    ```
2. Configure your global set:

```
namespace App\Globals;

use Tdwesten\StatamicBuilder\BaseGlobalSet;

class SiteSettings extends BaseGlobalSet
{
    public static function handle(): string
    {
        return 'site_settings';
    }

    public function title(): string
    {
        return 'Site Settings';
    }
}
```

By default, the global set will use the default site. You can override the `sites()` method to support multiple sites.

#### Blueprint for Global Sets

[](#blueprint-for-global-sets)

To define fields for your global set, create a blueprint with the same handle in the `globals` namespace:

```
namespace App\Blueprints\Globals;

use Tdwesten\StatamicBuilder\Blueprint;
use Tdwesten\StatamicBuilder\FieldTypes\Section;
use Tdwesten\StatamicBuilder\FieldTypes\Text;
use Tdwesten\StatamicBuilder\FieldTypes\Tab;

class SiteSettingsBlueprint extends Blueprint
{
    public static function handle(): string
    {
        return 'site_settings';
    }

    public static function blueprintNamespace(): string
    {
        return 'globals';
    }

    public function registerTabs(): array
    {
        return [
            Tab::make('General', [
                Section::make('General', [
                    Text::make('site_name')
                        ->displayName('Site Name')
                        ->required()
                ]),
            ]),
        ];
    }
}
```

Asset Containers
----------------

[](#asset-containers)

Generate an asset container:

```
php artisan make:asset-container Main
```

```
namespace App\AssetContainers;

use Tdwesten\StatamicBuilder\BaseAssetContainer;

class Main extends BaseAssetContainer
{
    public static function handle(): string
    {
        return 'main';
    }

    public function title(): string
    {
        return 'Main Assets';
    }

    public function disk(): string
    {
        return 'public';
    }
}
```

Most methods in `BaseAssetContainer` have default implementations, so you only need to override what you want to change (e.g., `disk()`, `allowUploads()`, `createFolders()`).

Navigations
-----------

[](#navigations)

Generate a navigation:

```
php artisan make:navigation Main
```

```
namespace App\Navigations;

use Tdwesten\StatamicBuilder\BaseNavigation;

class Main extends BaseNavigation
{
    public static function handle(): string
    {
        return 'main';
    }

    public function collections(): array
    {
        return ['pages'];
    }

    public function maxDepth(): ?int
    {
        return 3;
    }
}
```

Multi-site Support
------------------

[](#multi-site-support)

Generate a site:

```
php artisan make:site Blog
```

### Working with Foreign Fieldsets

[](#working-with-foreign-fieldsets)

When working with a mixed codebase or utilizing other Statamic addons, you can import their fieldsets using `ForeignFieldset` and `ForeignField`.

```
use Tdwesten\StatamicBuilder\FieldTypes\ForeignField;
use Tdwesten\StatamicBuilder\FieldTypes\ForeignFieldset;

// In your registerTabs() method:
Section::make('External', [
    ForeignFieldset::make('statamic-peak-seo::seo_basic')
        ->prefix('myseo_'),

    ForeignField::make('mytext', 'foreign_fields.bard')
        ->config([
            'width' => '25',
            'display' => "My Bard Field",
            'validate' => 'required',
        ])
]),
```

Supported Field Types
---------------------

[](#supported-field-types)

Statamic Builder supports all core Statamic field types. Use the `make($handle)` method to instantiate them.

Field TypeClassArray`Arr`Assets`Assets`Bard`Bard`Button Group`ButtonGroup`Checkboxes`Checkboxes`Code`Code`Collections`Collections`Color`Color`Date`Date`Dictionary`Dictionary`Entries`Entries`Float`FloatVal`Form`Form`Grid`Grid`Group`Group`Hidden`Hidden`HTML`Html`Icon`Icon`Integer`Integer`Link`Link`Lists`Lists`Markdown`Markdown`Money`Money`Navs`Navs`Number`Number`Password`Password`Radio`Radio`Range`Range`Rating`Rating`Replicator`Replicator`Reveal`Revealer`Section`Section`Select`Select`Sites`Sites`Slug`Slug`Spacer`Spacer`Structures`Structures`Table`Table`Taggable`Taggable`Taxonomies`Taxonomies`Template`Template`Terms`Terms`Text`Text`Textarea`Textarea`Time`Time`Toggle`Toggle`User Groups`UserGroups`User Roles`UserRoles`Users`Users`Video`Video`Width`Width`YAML`Yaml`... and many more.### Custom Fields

[](#custom-fields)

You can create a custom field by extending the `Field` class or using the generator:

```
composer generate-field MyField
```

Artisan Commands
----------------

[](#artisan-commands)

CommandDescription`make:blueprint`Create a new Blueprint class.`make:fieldset`Create a new Fieldset class.`make:collection`Create a new Collection class.`make:taxonomy`Create a new Taxonomy class.`make:global-set`Create a new Global Set class.`make:navigation`Create a new Navigation class.`make:asset-container`Create a new Asset Container class.`make:site`Create a new Site class.`statamic-builder:export`Export definitions to YAML.Exporting to YAML
-----------------

[](#exporting-to-yaml)

If you need to generate standard Statamic YAML files from your PHP definitions:

```
php artisan statamic-builder:export
```

Changes
-------

[](#changes)

### Version 1.1.0 (Refactoring &amp; Auto-discovery)

[](#version-110-refactoring--auto-discovery)

- **Base Classes**: `BaseCollection`, `BaseGlobalSet`, and `BaseNavigation` now provide default implementations for several methods that were previously abstract. While this simplifies new components, ensure your existing components still behave as expected if they were relying on the previous abstract structure.
- **Search Index**: `BaseCollection::searchIndex()` return type is now nullable (`?string`).
- **Blueprints**: Blueprints now prefer static `handle()` and `blueprintNamespace()` methods for better auto-discovery support.

### Version 1.2.0 (Enhanced Components &amp; Commands)

[](#version-120-enhanced-components--commands)

- **Global Sets &amp; Navigations**: Fully integrated with Statamic repositories, allowing for saving and better multi-site support.
- **New Commands**: Added `make:site` and `make:asset-container` for faster development.
- **Generator Refactoring**: Unified logic for all generator commands.
- **Field Types**: Added several new field types including `Color`, `Hidden`, `Money`, `Number`, `Password`, `Rating`, `Time`, and `Video`.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance84

Actively maintained with recent releases

Popularity38

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 79% 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 ~31 days

Recently: every ~78 days

Total

25

Last Release

83d ago

Major Versions

v0.1.3 → v1.0.02024-03-25

v1.1.0 → v2.0.02026-01-04

v2.0.0 → v3.0.02026-02-24

PHP version history (2 changes)v0.1.0.alphaPHP ^8.2

v3.0.0PHP ^8.3

### Community

Maintainers

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

---

Top Contributors

[![tdwesten](https://avatars.githubusercontent.com/u/224501?v=4)](https://github.com/tdwesten "tdwesten (249 commits)")[![tylerdak](https://avatars.githubusercontent.com/u/20099759?v=4)](https://github.com/tylerdak "tylerdak (14 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (12 commits)")[![benatoff](https://avatars.githubusercontent.com/u/146389211?v=4)](https://github.com/benatoff "benatoff (8 commits)")[![BobWez98](https://avatars.githubusercontent.com/u/23509926?v=4)](https://github.com/BobWez98 "BobWez98 (8 commits)")[![kgirzadas](https://avatars.githubusercontent.com/u/11364908?v=4)](https://github.com/kgirzadas "kgirzadas (7 commits)")[![mvanpijkeren](https://avatars.githubusercontent.com/u/74592719?v=4)](https://github.com/mvanpijkeren "mvanpijkeren (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![danielbrodin](https://avatars.githubusercontent.com/u/696872?v=4)](https://github.com/danielbrodin "danielbrodin (2 commits)")[![duncandejong](https://avatars.githubusercontent.com/u/3210606?v=4)](https://github.com/duncandejong "duncandejong (2 commits)")[![evelynfredin](https://avatars.githubusercontent.com/u/45714191?v=4)](https://github.com/evelynfredin "evelynfredin (2 commits)")[![Jade-GG](https://avatars.githubusercontent.com/u/32514269?v=4)](https://github.com/Jade-GG "Jade-GG (1 commits)")[![duncan412](https://avatars.githubusercontent.com/u/44285115?v=4)](https://github.com/duncan412 "duncan412 (1 commits)")[![indykoning](https://avatars.githubusercontent.com/u/15870933?v=4)](https://github.com/indykoning "indykoning (1 commits)")[![dotninth](https://avatars.githubusercontent.com/u/25880190?v=4)](https://github.com/dotninth "dotninth (1 commits)")

---

Tags

laravelstatamic-addon

###  Code Quality

TestsPest

Static AnalysisRector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/tdwesten-statamic-builder/health.svg)

```
[![Health](https://phpackages.com/badges/tdwesten-statamic-builder/health.svg)](https://phpackages.com/packages/tdwesten-statamic-builder)
```

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[marcorieser/statamic-livewire

A Laravel Livewire integration for Statamic.

2381.5k10](/packages/marcorieser-statamic-livewire)[swiftmade/statamic-clear-assets

Deletes unused assets. Saves storage space.

1938.6k](/packages/swiftmade-statamic-clear-assets)[aerni/livewire-forms

A Statamic forms framework powered by Laravel Livewire

2912.8k](/packages/aerni-livewire-forms)[visuellverstehen/statamic-classify

A useful helper to add CSS classes to all HTML tags generated by the bard editor.

20116.8k](/packages/visuellverstehen-statamic-classify)[mitydigital/feedamic

A fully-featured RSS and Atom feed generator for Statamic.

1064.0k](/packages/mitydigital-feedamic)

PHPackages © 2026

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