PHPackages                             dovetaily/crafteus - 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. [Templating &amp; Views](/categories/templating)
4. /
5. dovetaily/crafteus

ActiveLibrary[Templating &amp; Views](/categories/templating)

dovetaily/crafteus
==================

An advanced tool for generating stub files from custom 'Ecosystems'. Designers can create Ecosystems composed of multiple dynamic Templates, defining specific configurations and transformation logic. Users can leverage these Ecosystems to provide data, which will be processed by the designers' configurations and transformed into tailored stub files.

1.0.0(11mo ago)110Apache-2.0PHPPHP ^8.1

Since Jan 23Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/dovetaily/crafteus)[ Packagist](https://packagist.org/packages/dovetaily/crafteus)[ Docs](https://github.com/dovetaily/crafteus)[ RSS](/packages/dovetaily-crafteus/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (1)DependenciesVersions (4)Used By (0)

Crafteus
========

[](#crafteus)

Crafteus is an advanced tool for generating stub files from custom 'Ecosystems'. Designers can create Ecosystems composed of multiple dynamic Templates, defining specific configurations and transformation logic. Users can leverage these Ecosystems to provide data, which will be processed by the designers' configurations and transformed into tailored stub files.

How to Install
--------------

[](#how-to-install)

You can install **Crafteus** via Composer by running the following command:

```
composer require dovetaily/crafteus
```

Usage
-----

[](#usage)

Once installed, you can start using **Crafteus** to generate stub files based on your custom Ecosystems.

### Basic Usage

[](#basic-usage)

#### Create your Ecosystem

[](#create-your-ecosystem)

```
use Crafteus\Environment\Ecosystem;

class MyEcosystem extends Ecosystem
{
	public function template() : array {
		return [
			'my-template1' => [
				'config' => [
					// Required keys
					'path' => '../absolute-path-where-the-file-will-be-generated',
					'extension' => 'extension-of-the-generated-file',
					'stub_file' => "../your-absolute-path-of-the-stub-file",
					'generate' => true,

					// Optional keys
					'templating' => null,

					// 'your_custom_configuration_key' => 'value', // key names must follow PHP variable naming conventions.
				],
			],
			'my-template2-class' => MyTemplate::class, // In advance usage
		];
	}
}
```

##### Configuration Keys

[](#configuration-keys)

1. **`path`** (Required)

    - **Type:** `string` | `array`
    - **Description:** Specifies the path(s) where the generated file(s) will be created.
        - Example (Single Path): ```
             'path' => __DIR__ . "/your-path/folder"
            ```
        - Example (Multiple Paths): ```
             'path' => [
             	'key_path1' => __DIR__ . "/path1",
             	'key_path2' => __DIR__ . "/path2"
             ]
            ```
    - **Note:** If multiple paths are provided in `path`, you can make them match with the other configuration keys (extension, stub\_file, ...) otherwise the multiple paths will take the first existing configuration key.
2. **`extension`** (Required)

    - **Type:** `string` | `array`
    - **Description:** Defines the file extension for the generated file(s).
        - Example (Single Extension): ```
             'extension' => 'php'
            ```
        - Example (Multiple Extensions): ```
             'extension' => [
             	'key_path1' => 'php',
             	'key_path2' => 'txt'
             ]
            ```
3. **`stub_file`** (Required)

    - **Type:** `string` | `array`
    - **Description:** Indicates the absolute path(s) to the stub file(s) used as a template. Stub files define the structure/content of the generated file(s).
        - Example: ```
             'stub_file' => __DIR__ . "/../file.stub"
            ```
        - Example (Multiple Extensions): ```
             'stub_file' => [
             	'key_path1' => __DIR__ . "/../file1.stub",
             	'key_path2' => "path/file2.model"
             ]
            ```
4. **`generate`** (Required)

    - **Type:** `bool` | `array`
    - **Description:** Determines whether the file(s) should be generated. If `false`, no file will be created.
        - Example: ```
             'generate' => true
            ```
        - Example (Multiple Generates): ```
             'generate' => [
             	'key_path1' => true,
             	'key_path2' => false
             ]
            ```
5. **`templating`** (Optional)

    - **Type:** `string` | `\Closure` | `array`
    - **Description:** Specifies custom logic for templating. You can use a closure or reference a class to manipulate the stub's content dynamically.
        - Example (Closure): ```
             'templating' => function (\Crafteus\Environment\Stub $stub) {
             		$stub->getData(); // Data sent to the ecosystem
             		$stub->getCurrentContent(); // Retrieves the current content of the stub.
             		$stub->setCurrentContent(string|null $content); // Sets the current content of the stub.
             }
            ```
        - Example (Class): ```
             'templating' => MyTemplating::class // In advance usage
            ```
        - Example (Multiple Templating): ```
             'templating' => [
             	'key_path1' => function($stub){/*...*/},
             	'key_path2' => MyTemplating::class // In advance usage
             ]
            ```

#### Usage of Ecosystem

[](#usage-of-ecosystem)

##### **1. Building Your Crafteus Application**

[](#1-building-your-crafteus-application)

You can initialize a **Crafteus** instance using the `make()` method, which accepts the following parameters:

- **`ecosystem`** *(string)*: The class of your ecosystem.
- **`data`** *(array)*: The data to be injected into the ecosystem.
- **`templates_config`** *(array, optional)*: Default template configurations.

###### **Example:**

[](#example)

```
// index.php

use Crafteus\Crafteus;
use MyEcosystem;

$crafteusApp = Crafteus::make(
    ecosystem: MyEcosystem::class,
    data: [
        'foundation1', // This will be the filename, but the ecosystem can modify it if needed.
        'foundation2' => [
            'data' => [ // Data sent to the ecosystem
                'first-key' => 'value',
                // ...

                // You can also filter specific data per template
                "__template" => [
                    'my-template1' => [
                        'first-key' => 'value-change'
                    ]
                ]
            ],
            'config' => [
                'template' => [
                    'my-template1' => [
                        'path' => '../apply-this-path-only-for-this-foundation',
                        'generate' => false
                    ]
                ]
            ]
        ],
    ],
    templates_config: [
        'my-template1' => [
            'path' => 'change-default-path'
        ]
    ]
);
```

📌 **Note:** The method `make(string $ecosystem, array $data, array $templates_config = [])` returns an instance of `Crafteus\Environment\App`.

##### **2. Generating Files**

[](#2-generating-files)

Once the Crafteus application is created, you can generate files for your ecosystem using the `generate()` method:

```
$crafteusApp->generate();
```

📌 **Expected Output:** A structured array containing the results of the file generation for each foundation and its associated templates.

```
[
    'foundation1' => [
        'my-template1' => true, // Will Generate "/..my-template1-path/foundation1.php"
        'my-template2-class' => true, // Will Generate "/..my-template2-path/foundation1.php"
    ],
    'foundation2' => [
        'my-template1' => [
            'generated' => [/* List of generated Stub objects */],
            'not_generated' => [
                'key_path' => Object, // Instance of Crafteus\Environment\Stub
            ]
        ],
        'my-template2-class' => true, // Will Generate "/..my-template2-path/foundation2.php"
    ],
];
```

📌 **Error Handling:**
If a stub fails to generate, you can retrieve the related errors using:

```
$crafteusApp->generate()['foundation2']['my-template1']['not_generated']['key_path']->getErrors();
```

🔹 If this returns an empty array, it means the template's `generate` configuration was set to `false`.

###### **Generating a Specific Foundation**

[](#generating-a-specific-foundation)

You can also generate files for a single foundation:

```
$crafteusApp->getFoundation('foundation1')->getEcosystemInstance()->generateTemplates();
// or more simply
$crafteusApp->foundation1->generateTemplates();

$crafteusApp->getFoundation('foundation1')->generateEcosystem();
```

📌 **Expected Output:**

```
[
    'my-template1' => true,
    'my-template2-class' => true,
]
```

##### **3. Cancelling Generated Files**

[](#3-cancelling-generated-files)

If you need to cancel the generated files, use the following methods:

```
$crafteusApp->getFoundation('foundation1')->getEcosystemInstance()->cancelTemplatesGenerated();
// or
$crafteusApp->foundation1->cancelTemplatesGenerated();

$crafteusApp->getFoundation('foundation1')->cancelGeneratedEcosystem();
$crafteusApp->cancelGenerated();
```

📌 **Behavior:**

- If the generated file already exists, its content will be reset.
- If the file does not exist, it will be deleted.

### Advance Usage

[](#advance-usage)

Coming soon ...

**Features** ✨
--------------

[](#features-)

- ✅ **Define powerful Ecosystems**: Organize file generation using structured **Ecosystems** that group multiple **Templates**.
- ⚡ **Flexible Template Configuration**: Control **file paths, extensions, stub sources, and generation rules** dynamically.
- 🔧 **Custom Transformations**: Modify stub content using **closures, custom classes, or predefined logic** before file generation.
- 🔗 **Multi-Path &amp; Multi-Format Support**: Generate files in **multiple locations** with different **extensions** from a single template.
- 📂 **Batch File Generation**: Generate multiple files at once, with independent configurations for each.
- 🔄 **Rollback &amp; Error Handling**: Easily cancel generated files or retrieve errors to debug failed generations.
- 🔥 **Dynamic Data Injection**: Pass structured **data arrays** to personalize generated content.
- 📌 **Seamless PHP Integration**: Works with any PHP project, requiring only **Composer** to install and use.

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

[](#requirements)

- PHP 8.1 or higher
- Composer

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

[](#contributing)

Contributions are welcome! Feel free to submit issues or pull requests on [GitHub](https://github.com/dovetaily/crafteus).

License
-------

[](#license)

Crafteus is open-source software licensed under the Apache-2.0 License.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance50

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Every ~0 days

Total

2

Last Release

349d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/17d570dfe8fc30391710c94819f211852c09a60ee8fd2da19a6043b44564f50c?d=identicon)[gedeontimothy](/maintainers/gedeontimothy)

---

Top Contributors

[![gedeontimothy](https://avatars.githubusercontent.com/u/40833547?v=4)](https://github.com/gedeontimothy "gedeontimothy (44 commits)")

---

Tags

phpconfigurationstubgeneratortemplateecosystemfile generatordynamic templatesfile generationstub generationstub generator

### Embed Badge

![Health badge](/badges/dovetaily-crafteus/health.svg)

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

###  Alternatives

[tomatophp/filament-plugins

Manage your modules as a plugin system with plugin generator

644.7k2](/packages/tomatophp-filament-plugins)

PHPackages © 2026

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