Build your first Copilot-powered Laravel app
In this guide, you build a command-line assistant with the Laravel Copilot SDK. You start with a single prompt, then move to sessions, events, and tools.Prerequisites
Before you begin, make sure you have:- GitHub Copilot CLI installed and authenticated
- PHP
8.4+ - Laravel
13.x
Install the SDK
Install the package with Composer:.env:
Send your first message
Create a command and callCopilot::run():
Keep context with sessions
UseCopilot::start() when you need multiple prompts in one conversation:
Handle session events
Register an event handler withon() to inspect assistant messages and failures:
Add a custom tool
Define a tool with a JSON schema and a handler:Build an interactive assistant
Combine sessions, events, and tools into an interactive Artisan command:How tools work
When you define a tool, you provide:- What the tool does.
- Which parameters it accepts.
- Which handler code should run.
Explore more features
Connect to MCP servers
Create custom agents
Customize the system message
Connect to an external CLI server
Run the Copilot CLI in server mode:.env:
COPILOT_URL is set, the SDK connects to that server instead of starting a new CLI process.
Telemetry and observability
Configure telemetry inconfig/copilot.php:
Learn more
- Authentication
- MCP
- Custom providers
- Telemetry
- Session config
- SessionEvent
- Laravel Copilot SDK overview
- Official SDK repository
Next steps
Authentication
Choose the right auth method for local and CI environments.
Tools
Let Copilot call your application code.
Session config
Configure models, hooks, MCP servers, and runtime behavior.
MCP
Connect pre-built tools from MCP servers.
Custom providers
Integrate additional provider and model strategies.
Telemetry
Export traces for debugging and observability.
Source references: Laravel Copilot SDK README, Laravel Copilot SDK Getting Started, and GitHub Copilot SDK.