承接 mariojgt/witchcraft 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mariojgt/witchcraft

Composer 安装命令:

composer require mariojgt/witchcraft

包简介

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

README 文档

README

Witchcraft Showcase

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

Watch Demo

✨ 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

Install

composer require mariojgt/witchcraft

Setup

php artisan migrate

Use

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

📝 Simple Usage Examples

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

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

Get Workflow Information

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

🎯 Built-in Node Types

Node Type Purpose Example Use
Model Select Database triggers Run workflow when user is created
Condition Decision logic If status = "active" then...
API Request External calls Send data to third-party service
Artisan Command Laravel commands Clear cache, send emails
Notification Alerts & messages Send user notifications
Variable Data manipulation Store and modify values
JSON Extract Data parsing Extract values from API responses

🔧 Advanced Features

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

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

Simulation Tracking

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

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

1. Generate Node

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

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

npm run build

🔗 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

Vite Setup (vite.config.js)

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

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

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

Data Backup

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

🛠️ Helper Functions Reference

Function Purpose Returns
witchcraft_trigger($code, $data) Execute workflow Mixed result
witchcraft_safe_trigger($code, $data) Execute with error handling Array with success/error
witchcraft_exists($code) Check if workflow exists Boolean
witchcraft_info($code) Get workflow details Array with metadata
witchcraft_execute($code, $data) Alias for trigger Mixed result
witchcraft_run($code, $data) Alias for trigger Mixed result

📊 Workflow Management

Access Editor

/witchcraft

Key Features

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

📚 Advanced Usage

Conditional Workflows

Create complex decision trees with condition nodes:

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

API Integration Workflows

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

Batch Processing

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

🤝 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

This package is open-sourced software licensed under the MIT license.

👨‍💻 Credits

🚀 Ready to automate your workflows?

Install Witchcraft →

mariojgt/witchcraft 适用场景与选型建议

mariojgt/witchcraft 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 3.02k 次下载、GitHub Stars 达 32, 最近一次更新时间为 2025 年 01 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「media」 「library」 「laravel」 「media library」 「tailwind」 「vue js」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mariojgt/witchcraft 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mariojgt/witchcraft 我们能提供哪些服务?
定制开发 / 二次开发

基于 mariojgt/witchcraft 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.02k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 32
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 32
  • Watchers: 4
  • Forks: 3
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-27