几天内即可获得 Laravel 代码审查方面的专家指导

ArtisanFlow: A Flowchart Engine for Laravel and Alpine.js

最后更新于 经过

ArtisanFlow: A Flowchart Engine for Laravel and Alpine.js image

ArtisanFlow is a new package by Zac Hiler that brings node-based flowchart UIs to Laravel applications. It ships in alpha and consists of two packages: AlpineFlow , the core frontend engine built on Alpine.js, and WireFlow , the Laravel companion that wraps it in Blade components and a Livewire trait.

Rather than render functions or JSX, you build flows with x-flow-* Alpine directives — or with WireFlow, plain Blade components with no custom JavaScript required.

主要特点

Some of the key features include:

  • Directive-driven — everything is an Alpine directive; no render functions or JSX needed
  • Animation engine — built-in support for timelines, particles, path motion, and camera tracking, all in a single animation loop
  • Deep nesting — nodes support parent/child hierarchies with type validation, child count limits, and auto-stacking
  • Zero-JS Livewire integration — install via Composer and use Blade components with multiple sync modes and server-side control
  • Smart edge routing — edges automatically route around nodes using avoidant or orthogonal path algorithms
  • AI-ready docs — ships with Laravel Boost skills for IDE integration so AI tools understand the API from the start

安装

For a Laravel app, install WireFlow via Composer:

作曲家 要求 getartisanflow/wireflow

Then run the install command, which publishes the assets and wires up the imports:

php 工匠 wireflow:install
npm 跑步 建造

WireFlow bundles AlpineFlow alongside it, so you don't need a separate npm install for the core. The service provider auto-discovers, and after the build step <x-flow> is ready to use in any Blade view.

Building a Flow

The typical setup is a Livewire component holding your node and edge data, paired with a Blade view using <x-flow>

Nodes and edges are plain PHP arrays. Each node needs an id , A positiondatalabel , while edges need at least an id , source , 和 target :

使用 Livewire\组件 ;
班级 DemoFlow 延伸 成分
{
民众 大批 节点 = [
[
'ID' => ‘1’ ,
'position' => [ 'x' => 20 , '和' => 120 ],
'班级' => 'flow-node-info' ,
'数据' => [ '标签' => 'Input' ]
],
[
'ID' => '2' ,
'position' => [ 'x' => 250 , '和' => 120 ],
'班级' => 'flow-node-primary' ,
'数据' => [ '标签' => 'Process' ]
],
[
'ID' => '3' ,
'position' => [ 'x' => 500 , '和' => 120 ],
'班级' => 'flow-node-success' ,
'数据' => [ '标签' => 'Output' ]
],
];
民众 大批 $edges = [
[
'ID' => 'e1-2' ,
'来源' => ‘1’ ,
'目标' => '2' ,
'animated' => 'dot' ,
'particleColor' => '#3b82f6'
],
[
'ID' => 'e2-3' ,
'来源' => '2' ,
'目标' => '3' ,
'animated' => 'dot' ,
'particleColor' => '#a855f7'
],
];
民众 功能 使成为 ()
{
返回 看法 'livewire.demo-flow' (英文):
}
}

The Blade view passes those arrays to <x-flow> and defines the node template inside an <x-slot:node> :

< x-flow :nodes = "$nodes" :edges = "$edges" >
< x-slot:node >
< x-flow-handle 类型 = "target" 位置 = "left" />
< 跨度 x-文本 = "node.data.label" ></ 跨度 >
< x-flow-handle 类型 = “来源” 位置 = "right" />
</ x-slot:node >
</ x-flow >

<x-flow-handle> marks connection points. Handles with type="source" initiate edges, and type="target" receives them. Inside the node slot, node is a reactive Alpine object, so any Alpine expression works — :class , x-show , x-text , and so on:

< x-slot:node >
< x-flow-handle 类型 = "target" 位置 = “顶部” />
< 跨度 x-文本 = "node.data.label" ></ 跨度 >
< 跨度 x-show = "node.selected" 班级 = "text-blue-500 text-xs" >Selected</ 跨度 >
< x-flow-handle 类型 = “来源” 位置 = "bottom" />
</ x-slot:node >

Canvas Features

Several canvas features can be toggled via props on <x-flow> :

< x-flow
:nodes = "$nodes"
:edges = "$edges"
背景 = "dots"
:controls = “真的”
:minimap = “真的”
:fit-view-on-init = “真的”
:history = “真的”
>

background 接受 "dots" , "lines" , "cross" , 或者 "none"controls adds zoom and fit-view buttons. minimap renders an overview panel. fit-view-on-init centres all nodes on first load. history enables undo/redo with Ctrl+Z / Ctrl+Y

Custom Node Types

For flows with multiple node types, you can register separate Blade views per type using :node-types :

< x-flow
:nodes = "$nodes"
:edges = "$edges"
:node-types = "[
'input' => 'flow.nodes.input-node',
'output' => 'flow.nodes.output-node',
]"
>

Then set type on individual nodes in your PHP array, and WireFlow will stamp the matching view. Nodes without a matching type fall back to the default slot.

Handling Events

User interactions on the canvas — connecting nodes, clicking, dragging — fire events you can listen to on <x-flow> :

< x-flow
:nodes = "$nodes"
:edges = "$edges"
@connect ="onConnect"
@node-click = "onNodeClick"
@node-drag-end = "onNodeDragEnd"
>

These route to methods on your Livewire component. Add the WithWireFlow trait and define the handlers:

使用 ArtisanFlow\WireFlow\Concerns\WithWireFlow ;
班级 DemoFlow 延伸 成分
{
使用 WithWireFlow ;
民众 功能 onConnect 细绳 $source, 细绳 $target) : 空白
{
$this -> edges[] = [
'ID' => "e-{ $source }-{ $target }” ,
'来源' => $source,
'目标' => $target,
];
}
民众 功能 onNodeClick 细绳 $id) : 空白
{
// handle click
}
民众 功能 onNodeDragEnd 细绳 $id, 漂浮 $x, 漂浮 $y) : 空白
{
// persist the new position
}
}

Server-Driven Updates

WithWireFlow trait also exposes methods for pushing changes to the canvas from the server — adding or removing nodes, controlling the viewport, triggering animations, and more:

民众 功能 addStep () : 空白
{
$this -> flowAddNodes ([
[ 'ID' => 'new-1' , 'position' => [ 'x' => 300 , '和' => 100 ], '数据' => [ '标签' => 'New Step' ]],
]);
}
民众 功能 focusCanvas () : 空白
{
$this -> flowFitView ();
}
民众 功能 resetCanvas () : 空白
{
$this -> flowClear ();
}

For methods that dispatch canvas commands without updating Livewire state, Livewire 3.3+'s #[Renderless] attribute skips the re-render:

#[ Renderless ]
民众 功能 zoomToFit () : 空白
{
$this -> flowFitView ();
}

Sync Modes

By default, WireFlow sends node and edge data to the canvas as initial values and leaves state management on the client. You can flip this with two props:

  • :sync="true" — two-way binding via Livewire's entangle() . Every drag or connection syncs back to $nodes$edges on the server automatically.
  • :listen="true" — read-only canvas; users can't drag or connect. Useful for dashboards that push state changes.

Laravel Boost Skills

ArtisanFlow also ships with Laravel Boost skills, which provide AI-optimised documentation that tools like Claude Code and Cursor can consume directly. The idea is that your AI assistant understands the ArtisanFlow API out of the box — directives, components, trait methods — without you having to paste docs into context or explain the API yourself.

Live Collaboration

ArtisanFlow also includes a collaboration add-on that enables real-time multi-user editing. It automatically syncs node and edge changes across connected clients, supports remote cursors, shared selections, and Laravel Reverb as a provider.

笔记: At the time of writing, ArtisanFlow is in alpha, but already has a solid feature set worth keeping an eye on.

Follow along with Zac as he continues development, explore the source code on GitHub , and check out the 完整文档 to dig deeper.

Yannick Lyn Fatt 的照片

Laravel News 的特约撰稿人和全栈 Web 开发人员。

归档于:
立方体

Laravel 时事通讯

加入超过 4 万名开发者的行列,不错过任何新的技巧、教程等内容。

图像
SerpApi

适用于您的 LLM 和 AI 应用的 Web 搜索 API

访问 SerpApi
Tinkerwell 徽标

廷克威尔

Laravel 开发者必备的代码运行器。可在本地和生产环境中体验 AI、自动补全和即时反馈功能。

廷克威尔
几天内即可获得 Laravel 代码审查徽标的专家指导

几天内即可获得 Laravel 代码审查方面的专家指导

专家级代码审查!两位拥有 10 年以上 Laravel 开发经验的开发者将为您提供清晰、实用的反馈,帮助团队构建更优质的应用程序。

几天内即可获得 Laravel 代码审查方面的专家指导
PhpStorm 标志

PhpStorm

首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

PhpStorm
Laravel Cloud 标志

Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

Laravel 云
了解 Softtech 的标志

了解软科技

Acquaint Softtech 提供 AI 就绪的 Laravel 开发人员,48 小时内即可上手,每月费用为 3000 美元,没有冗长的销售流程,并提供 100% 退款保证。

了解软科技
Kirschbaum 标志

樱桃树

提供创新和稳定性,确保您的Web应用程序取得成功。

樱桃树
Shift 标志

转移

还在运行旧版本的 Laravel?立即实现 Laravel 自动升级和代码现代化,让您的应用程序保持最新状态。

转移
鱼叉:新一代时间跟踪和发票标志

Harpoon:新一代时间跟踪和发票系统

新一代时间跟踪和计费软件,帮助您的机构规划和预测盈利的未来。

Harpoon:新一代时间跟踪和发票系统
Lucky Media 标志

幸运传媒

Get Lucky Now——拥有十余年经验的 Laravel 开发理想之选!

幸运传媒
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

SaaSykit 是一个多租户 Laravel SaaS 入门套件,包含运行现代 SaaS 所需的所有功能,例如支付、美观的结账界面、管理面板、用户仪表盘、身份验证、现成组件、统计数据、博客、文档等等。

SaaSykit:Laravel SaaS 入门套件
MongoDB 徽标

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB
Ship AI with Laravel: Stop Your AI Agent from Guessing image

Ship AI with Laravel: Stop Your AI Agent from Guessing

阅读文章
Laravel Cloud Adds Path Blocking to Prevent Bots From Waking Hibernated Apps image

Laravel Cloud Adds Path Blocking to Prevent Bots From Waking Hibernated Apps

阅读文章
Making Laravel MongoDB Operations Idempotent: Safe Retries for Financial Transactions image

Making Laravel MongoDB Operations Idempotent: Safe Retries for Financial Transactions

阅读文章
FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0 image

FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0

阅读文章
Pretty PHP Info: A Modern Replacement for `phpinfo()` image

Pretty PHP Info: A Modern Replacement for `phpinfo()`

阅读文章
Laracon US 2026 Announced image

Laracon US 2026 Announced

阅读文章