PHPackages                             mariojgt/witchcraft - 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. [Image &amp; Media](/categories/media)
4. /
5. mariojgt/witchcraft

ActiveLaravel[Image &amp; Media](/categories/media)

mariojgt/witchcraft
===================

A Laravel Package Witchcraft, a quick start for new laravel Packages

v2.0.6(7mo ago)312.6k↓50%2MITVuePHP ^8.0CI passing

Since Jan 27Pushed 7mo ago4 watchersCompare

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

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

Witchcraft: Laravel Workflow Automation
=======================================

[](#witchcraft-laravel-workflow-automation)

[![Witchcraft Showcase](https://raw.githubusercontent.com/mariojgt/witchcraft/refs/heads/main/art/showcase.png)](https://raw.githubusercontent.com/mariojgt/witchcraft/refs/heads/main/art/showcase.png)

> Create powerful workflows with a visual drag-and-drop editor. Perfect for automating business processes, data processing, and API integrations.

[![Watch Demo](https://camo.githubusercontent.com/6741f9024d570d7982ea7edb8a8dfcc7eed53064a312c6f35a01b366801834d7/68747470733a2f2f696d672e796f75747562652e636f6d2f76692f48695a64577852617878512f302e6a7067)](https://www.youtube.com/watch?v=HiZdWxRaxxQ)

✨ Features
----------

[](#-features)

- 🎨 **Visual Workflow Editor** - Drag, drop, and connect nodes
- 🔄 **Version Control** - Automatic versioning with rollback support
- 🛡️ **Protected Workflows** - Mark workflows as non-deletable
- 📊 **Simulation History** - Track all workflow executions
- 🔗 **Easy Integration** - Simple helper functions for triggering workflows
- 🎯 **Smart Triggers** - Execute workflows programmatically with unique codes

🚀 Quick Start
-------------

[](#-quick-start)

### Install

[](#install)

```
composer require mariojgt/witchcraft
```

### Setup

[](#setup)

```
php artisan migrate
```

### Use

[](#use)

```
// Execute any workflow with one line
$result = witchcraft_trigger('FLOW_MY_WORKFLOW', ['data' => 'value']);
```

📝 Simple Usage Examples
-----------------------

[](#-simple-usage-examples)

### Basic Workflow Execution

[](#basic-workflow-execution)

```
// Simple trigger
$result = witchcraft_trigger('FLOW_PROCESS_ORDER', [
    'order_id' => 123,
    'user_id' => 456
]);

// Safe trigger with error handling
$response = witchcraft_safe_trigger('FLOW_SEND_EMAIL', ['email' => 'user@example.com']);
if ($response['success']) {
    echo "Email sent successfully!";
} else {
    echo "Error: " . $response['error'];
}
```

### Check if Workflow Exists

[](#check-if-workflow-exists)

```
if (witchcraft_exists('FLOW_BACKUP_DATA')) {
    $result = witchcraft_trigger('FLOW_BACKUP_DATA');
}
```

### Get Workflow Information

[](#get-workflow-information)

```
$info = witchcraft_info('FLOW_GENERATE_REPORT');
echo "Workflow: {$info['name']} (Version {$info['version']})";
```

🎯 Built-in Node Types
---------------------

[](#-built-in-node-types)

Node TypePurposeExample Use**Model Select**Database triggersRun workflow when user is created**Condition**Decision logicIf status = "active" then...**API Request**External callsSend data to third-party service**Artisan Command**Laravel commandsClear cache, send emails**Notification**Alerts &amp; messagesSend user notifications**Variable**Data manipulationStore and modify values**JSON Extract**Data parsingExtract values from API responses🔧 Advanced Features
-------------------

[](#-advanced-features)

### Automatic Versioning

[](#automatic-versioning)

- ✅ **Auto-save versions** when workflow structure changes
- ✅ **Version history** with search and filtering
- ✅ **One-click restore** to any previous version
- ✅ **Version notes** to track what changed

### Workflow Protection

[](#workflow-protection)

```
// Mark workflow as protected (cannot be deleted)
$workflow->update(['is_deletable' => false]);
```

### Simulation Tracking

[](#simulation-tracking)

- 📊 **Complete execution logs** for every run
- 📈 **Success/failure statistics**
- ⏱️ **Performance metrics** and duration tracking
- 📋 **Downloadable execution reports**

### Smart Trigger Codes

[](#smart-trigger-codes)

```
// Latest version always uses clean trigger code
witchcraft_trigger('FLOW_MY_PROCESS', $data); // Always runs latest version

// Old versions get versioned codes automatically:
// V1: FLOW_MY_PROCESS_OLD_V1
// V2: FLOW_MY_PROCESS_OLD_V2
// V3: FLOW_MY_PROCESS (current/latest)
```

🎨 Creating Custom Nodes
-----------------------

[](#-creating-custom-nodes)

### 1. Generate Node

[](#1-generate-node)

```
php artisan witchcraft:make-node ProcessPayment --category=Payments
```

### 2. Create Handler

[](#2-create-handler)

```
namespace App\Witchcraft\Handlers;

use Mariojgt\Witchcraft\Contracts\NodeHandlerInterface;

class ProcessPaymentNodeHandler implements NodeHandlerInterface
{
    public function getMetadata(): array
    {
        return [
            'type' => 'process-payment',
            'category' => 'Payments',
            'icon' => 'CreditCardIcon',        // Lucide icon
            'label' => 'Process Payment',
            'component' => 'ProcessPaymentNode',
            'initialData' => [
                'amount' => 0,
                'currency' => 'USD'
            ]
        ];
    }

    public function execute(array $nodeData, array $variables): array
    {
        // Your payment processing logic here
        $amount = $nodeData['amount'];

        // Process payment...

        return [
            'success' => true,
            'payment_id' => 'pay_123456',
            'status' => 'completed'
        ];
    }
}
```

### 3. Build Assets

[](#3-build-assets)

```
npm run build
```

🔗 Model Integration
-------------------

[](#-model-integration)

Add workflow triggers to your models:

```
use Mariojgt\Witchcraft\Traits\HasWitchcraftTriggers;

class Order extends Model
{
    use HasWitchcraftTriggers;

    // Workflows will automatically trigger on:
    // - created, updated, deleted events
    // - Any model changes
}
```

⚙️ Configuration
----------------

[](#️-configuration)

### Vite Setup (vite.config.js)

[](#vite-setup-viteconfigjs)

```
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
  plugins: [
    laravel({
      input: [
        'resources/vendor/Witchcraft/js/vue.js',
        'resources/vendor/Witchcraft/sass/app.scss',
      ],
      refresh: true,
    }),
    vue()
  ],
  build: {
    outDir: 'public/vendor/Witchcraft',
  }
});
```

🎯 Real-World Examples
---------------------

[](#-real-world-examples)

### E-commerce Order Processing

[](#e-commerce-order-processing)

```
// When order is created, trigger workflow
witchcraft_trigger('FLOW_PROCESS_ORDER', [
    'order_id' => $order->id,
    'customer_email' => $order->customer->email,
    'total' => $order->total
]);
```

### User Onboarding

[](#user-onboarding)

```
// Welcome new users
witchcraft_trigger('FLOW_USER_WELCOME', [
    'user_id' => $user->id,
    'email' => $user->email,
    'name' => $user->name
]);
```

### Data Backup

[](#data-backup)

```
// Daily backup workflow
witchcraft_trigger('FLOW_DAILY_BACKUP', [
    'date' => now()->toDateString(),
    'tables' => ['users', 'orders', 'products']
]);
```

🛠️ Helper Functions Reference
-----------------------------

[](#️-helper-functions-reference)

FunctionPurposeReturns`witchcraft_trigger($code, $data)`Execute workflowMixed result`witchcraft_safe_trigger($code, $data)`Execute with error handlingArray with success/error`witchcraft_exists($code)`Check if workflow existsBoolean`witchcraft_info($code)`Get workflow detailsArray with metadata`witchcraft_execute($code, $data)`Alias for triggerMixed result`witchcraft_run($code, $data)`Alias for triggerMixed result📊 Workflow Management
---------------------

[](#-workflow-management)

### Access Editor

[](#access-editor)

```
/witchcraft

```

### Key Features

[](#key-features)

- 🎨 **Drag &amp; drop** node creation
- 🔗 **Visual connections** between nodes
- 💾 **Auto-save** with version control
- 🔍 **Search &amp; filter** workflows
- 📁 **Category organization**
- 🛡️ **Protection settings**
- 📈 **Execution history**

📚 Advanced Usage
----------------

[](#-advanced-usage)

### Conditional Workflows

[](#conditional-workflows)

Create complex decision trees with condition nodes:

```
[Trigger] → [Check Status] → [If Active] → [Send Email]
                           → [If Inactive] → [Deactivate Account]

```

### API Integration Workflows

[](#api-integration-workflows)

```
[Trigger] → [API Request] → [Extract Data] → [Save to Database] → [Notify Admin]

```

### Batch Processing

[](#batch-processing)

```
[Schedule] → [Get Records] → [Process Each] → [Update Status] → [Generate Report]

```

🤝 Contributing
--------------

[](#-contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

👨‍💻 Credits
-----------

[](#‍-credits)

- [Mario Tarosso](https://github.com/mariojgt)
- [All Contributors](../../contributors)

---

### 🚀 Ready to automate your workflows?

[](#-ready-to-automate-your-workflows)

**[Install Witchcraft →](https://packagist.org/packages/mariojgt/witchcraft)**

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance62

Regular maintenance activity

Popularity31

Limited adoption so far

Community10

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 ~30 days

Recently: every ~23 days

Total

9

Last Release

229d ago

Major Versions

1.0.1 → 2.0.02025-06-26

### Community

Maintainers

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

---

Top Contributors

[![mariojgt](https://avatars.githubusercontent.com/u/7347012?v=4)](https://github.com/mariojgt "mariojgt (30 commits)")

---

Tags

laravellibrarymediatailwindmedia libraryvue js

### Embed Badge

![Health badge](/badges/mariojgt-witchcraft/health.svg)

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

###  Alternatives

[tomatophp/filament-media-manager

Manage your media files using spatie media library with easy to use GUI for FilamentPHP

14543.9k3](/packages/tomatophp-filament-media-manager)[classic-o/nova-media-library

Tool and field that will let you managing files and add them to the posts

154172.0k](/packages/classic-o-nova-media-library)

PHPackages © 2026

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