1. Go to this page and download the library: Download mariojgt/witchcraft library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mariojgt / witchcraft example snippets
// Execute any workflow with one line
$result = witchcraft_trigger('FLOW_MY_WORKFLOW', ['data' => 'value']);
// Mark workflow as protected (cannot be deleted)
$workflow->update(['is_deletable' => false]);
// 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)
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'
];
}
}
use Mariojgt\Witchcraft\Traits\HasWitchcraftTriggers;
class Order extends Model
{
use HasWitchcraftTriggers;
// Workflows will automatically trigger on:
// - created, updated, deleted events
// - Any model changes
}
// When order is created, trigger workflow
witchcraft_trigger('FLOW_PROCESS_ORDER', [
'order_id' => $order->id,
'customer_email' => $order->customer->email,
'total' => $order->total
]);