Download the PHP package swisnl/ag-ui-server without Composer
On this page you can find all versions of the php package swisnl/ag-ui-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download swisnl/ag-ui-server
More information about swisnl/ag-ui-server
Files in swisnl/ag-ui-server
Package ag-ui-server
Short Description PHP server integration for AG-UI - standardized AI agent frontend communication via Server-Sent Events
License MIT
Homepage https://github.com/swisnl/ag-ui-server
Informations about the package ag-ui-server
AG-UI Server for PHP
A PHP server integration package for AG-UI - standardized AI agent frontend communication via Server-Sent Events and other transport methods.
AG-UI provides a real-time, event-driven protocol for streaming AI agent responses, tool calls, and state updates to frontends. This package makes it easy to integrate AG-UI into your PHP AI projects.
Features
- Complete AG-UI Event Support - All event types: messages, tool calls, lifecycle, state management
- Flexible Message API - Simple one-shot messages or streaming with closures/iterables
- Pluggable Transporters - SSE included, easily extend with WebSocket, polling, etc.
- Adaptive Delta Buffering - Optimized streaming performance
- PSR-14 Compatible - Interoperable with existing event systems
- Type Safe - PHPStan types for better developer experience
- Framework Agnostic - Works with Laravel, Symfony, or any PHP application
Installation
Quick Start
Core Concepts
AG-UI Events
The package supports all AG-UI event types:
- Lifecycle:
RunStarted,RunFinished,RunError,StepStarted,StepFinished - Messages:
TextMessageStart,TextMessageContent,TextMessageEnd - Reasoning:
ReasoningStart,TextReasoningMessageStart,TextReasoningMessageContent,TextReasoningMessageEnd,TextReasoningEnd - Tool Calls:
ToolCallStart,ToolCallArgs,ToolCallEnd - State:
StateSnapshot,StateDelta,MessagesSnapshot - Special:
Raw,Custom
Flexible Message API
Transporters
Easily swap transport methods:
RAG Integration Example
Advanced Features
Manual Event Triggering
While AgUiState provides a convenient high-level API for typical AI workflows, you can also trigger events manually for complete control over your application's behavior:
Direct Event Dispatching (Without PSR-14)
If you prefer not to use PSR-14, you can send events directly:
When to Use Manual Events vs AgUiState
- Use
AgUiStatefor typical AI agent workflows with automatic state management, message streaming, and tool calls - Use manual events when you need:
- Complete control over event timing and data
- Integration with existing event-driven architectures
- Custom event flows that don't fit the standard AI agent pattern
- Building your own higher-level abstractions
Adaptive Delta Buffering
Delta buffering is optional and can be enabled to optimize streaming performance:
PSR-14 Event Integration
All AG-UI events implement PSR-14 interfaces:
Custom Transporters
Implement your own transport:
Event Types Reference
Message Events
TextMessageStart- Begin streaming a messageTextMessageContent- Content chunk (delta)TextMessageEnd- Message complete-
Reasoning Events
ReasoningStart- Begin reasoning state (optional)ReasoningMessageStart- Begin streaming a reasoning messageReasoningMessageContent- Content chunk (delta)ReasoningMessageEnd- Reasoning message completeReasoningStart- End reasoning state (optional)
Tool Call Events
ToolCallStart- Begin tool executionToolCallArgs- Tool arguments (can be streamed)ToolCallEnd- Tool execution completeToolCallResult- Results of a Tool execution
Lifecycle Events
RunStarted- Agent run beginsRunFinished- Agent run completes successfullyRunError- Agent run failedStepStarted- Processing step beginsStepFinished- Processing step completes
State Events
StateSnapshot- Complete stateStateDelta- State changes (JSON Patch)MessagesSnapshot- All conversation messages
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Joris Meijer
- All Contributors
License
This package is open-sourced software licensed under the MIT license.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
SWIS :heart: Open Source
SWIS is a web agency from Leiden, the Netherlands. We love working with open source software.