PHPackages                             revolution/laravel-copilot-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. revolution/laravel-copilot-sdk

ActiveLibrary[CLI &amp; Console](/categories/cli)

revolution/laravel-copilot-sdk
==============================

GitHub Copilot SDK for Laravel

1.0.3(1w ago)22.8k—5.9%[1 issues](https://github.com/invokable/laravel-copilot-sdk/issues)MITPHPPHP ^8.4CI passing

Since Jan 23Pushed 3w ago1 watchersCompare

[ Source](https://github.com/invokable/laravel-copilot-sdk)[ Packagist](https://packagist.org/packages/revolution/laravel-copilot-sdk)[ GitHub Sponsors](https://github.com/invokable)[ RSS](/packages/revolution-laravel-copilot-sdk/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (41)Versions (81)Used By (0)

GitHub Copilot SDK for Laravel
==============================

[](#github-copilot-sdk-for-laravel)

[![tests](https://github.com/invokable/laravel-copilot-sdk/actions/workflows/tests.yml/badge.svg)](https://github.com/invokable/laravel-copilot-sdk/actions/workflows/tests.yml)[![Maintainability](https://camo.githubusercontent.com/b53ae5af8478b18f25ab1471d4d7cc5ea4eb2be78eae0da26b81f11956835746/68747470733a2f2f716c74792e73682f6261646765732f65663931333063662d613935332d346431342d616330322d3965616662346334306130632f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/invokable/projects/laravel-copilot-sdk)[![Code Coverage](https://camo.githubusercontent.com/e3009c9be681f606d6727e8c62fd7749c9cf7dd06934d2c8bbe60c4cf8669f0f/68747470733a2f2f716c74792e73682f6261646765732f65663931333063662d613935332d346431342d616330322d3965616662346334306130632f636f7665726167652e737667)](https://qlty.sh/gh/invokable/projects/laravel-copilot-sdk)[![Ask DeepWiki](https://camo.githubusercontent.com/0f5ae213ac378635adeb5d7f13cef055ad2f7d9a47b36de7b1c67dbe09f609ca/68747470733a2f2f6465657077696b692e636f6d2f62616467652e737667)](https://deepwiki.com/invokable/laravel-copilot-sdk)

This package is Laravel version of [GitHub Copilot SDK](https://github.com/github/copilot-sdk), which allows you to interact with GitHub Copilot CLI programmatically from your Laravel applications.

Note

This is the Community SDK.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.4
- Laravel &gt;= 12.x
- [Copilot CLI](https://github.com/github/copilot-cli) Latest version

Installation
------------

[](#installation)

```
composer require revolution/laravel-copilot-sdk
```

Optional### .env (Optional)

[](#env-optional)

```
COPILOT_CLI_PATH=copilot
```

### TCP Mode (Optional)

[](#tcp-mode-optional)

Instead of starting a new CLI process for each request, you can connect to an existing Copilot CLI server running in TCP mode. This is useful for:

- Laravel Forge/Cloud deployments with background process management
- Sharing a single CLI instance across multiple Laravel processes
- Better performance with persistent connections

Start the Copilot CLI server:

```
copilot --headless --port 12345
```

Configure your `.env`:

```
COPILOT_URL=tcp://127.0.0.1:12345
```

When `COPILOT_URL` is set, the SDK will connect to the existing server instead of starting a new CLI process.

### Publish config (Optional)

[](#publish-config-optional)

```
php artisan vendor:publish --tag=copilot-config
```

### Uninstall

[](#uninstall)

```
composer remove revolution/laravel-copilot-sdk
```

Getting Started
---------------

[](#getting-started)

[Getting Started Guide](./docs/getting-started.md)

Usage
-----

[](#usage)

We provide a high-level API that uses a Laravel Facade on top of a layer that replicates the official SDK.

This should be sufficient for general use.

Artisan commands, controllers, jobs... the SDK can be used anywhere in Laravel where you can invoke the Copilot CLI.

### Run single prompt

[](#run-single-prompt)

```
use Revolution\Copilot\Facades\Copilot;

$response = Copilot::run(prompt: 'Tell me something about Laravel.');
dump($response->content());
```

### Multiple prompts in a single session

[](#multiple-prompts-in-a-single-session)

```
use Revolution\Copilot\Contracts\CopilotSession;
use Revolution\Copilot\Facades\Copilot;

$content = Copilot::start(function (CopilotSession $session) {
    dump('Starting Copilot session: '.$session->id());

    $response = $session->sendAndWait(prompt: 'Tell me something about PHP.');
    dump($response->content());

    $response = $session->sendAndWait(prompt: 'Tell me something about Laravel.');
    dump($response->content());

    return $response->content();
});

dump($content);
```

### `copilot()` helper

[](#copilot-helper)

Alternatively, you can use the `copilot()` helper function.

```
// Don't forget to import the function
use function Revolution\Copilot\copilot;

// If you specify a prompt as a string, it is the same as Copilot::run().
$response = copilot('Tell me something about Laravel.');

// If you pass a closure, it is the same as Copilot::start().
copilot(function (CopilotSession $session) {
    $response = $session->sendAndWait(prompt: 'Tell me something about PHP.');
});

// If you don't pass anything, it's the same as Facade.
dump(copilot()->client()->ping());
```

For more than simple use, use the Copilot Facade above.

Testing
-------

[](#testing)

Provide Laravel way testing support with `Copilot::fake()`.

### Copilot::fake()

[](#copilotfake)

`Copilot::fake()` is a mock for features used from the Copilot Facade. Other features are not mocked.

```
use Revolution\Copilot\Facades\Copilot;

Copilot::fake('2');

$response = Copilot::run(prompt: '1 + 1');

// Pest
expect($response->content())->toBe('2');
// PHPUnit
$this->assertEquals('2', $response->content());
```

When calling multiple times with Copilot::start()

```
use Revolution\Copilot\Facades\Copilot;
use Revolution\Copilot\Contracts\CopilotSession;

Copilot::fake([
    '*' => Copilot::sequence()
            ->push(Copilot::response('2'))
            ->push(Copilot::response('4')),
]);

Copilot::start(function (CopilotSession $session) use (&$response1, &$response2) {
    $response1 = $session->sendAndWait(prompt: '1 + 1');
    $response2 = $session->sendAndWait(prompt: '2 + 2');
});

expect($response1->content())->toBe('2');
```

### Assertions

[](#assertions)

Assert that a specific prompt was called.

```
Copilot::assertPrompt('1 + *');
```

Assert that a prompt was not called.

```
Copilot::assertNotPrompt('1 + *');
```

Assert the number of prompts called.

```
Copilot::assertPromptCount(3);
```

Assert that no prompts were called.

```
Copilot::assertNothingSent();
```

### Prevent stray requests

[](#prevent-stray-requests)

Prevent all JSON-RPC requests. If called, an exception `Revolution\Copilot\Exceptions\StrayRequestException` is thrown.

```
Copilot::preventStrayRequests();
```

When you want to allow only some commands.

```
Copilot::preventStrayRequests(allow: ['ping']);
```

Stop prevention.

```
Copilot::preventStrayRequests(false);
```

Only JSON-RPC requests are prevented, so starting a client is not prevented.

Documentation
-------------

[](#documentation)

### English

[](#english)

- [Laravel Copilot SDK Documentation](https://kawax.biz/en/packages/laravel-copilot-sdk)
- [Getting Started Guide](./docs/getting-started.md)

### Japanese

[](#japanese)

- [docs/jp](./docs/jp)
- [Laravel Copilot SDK Documentation](https://kawax.biz/jp/packages/laravel-copilot-sdk)

Our other packages
------------------

[](#our-other-packages)

- [laravel-boost-copilot-cli](https://github.com/invokable/laravel-boost-copilot-cli)
- [laravel-boost-phpstorm-copilot](https://github.com/invokable/laravel-boost-phpstorm-copilot)

License
-------

[](#license)

MIT

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance87

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 83.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

58

Last Release

7d ago

Major Versions

0.3.1 → 1.0.0-beta.12026-05-09

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77618633?v=4)[Revolution](/maintainers/revolution)[@Revolution](https://github.com/Revolution)

---

Top Contributors

[![kawax](https://avatars.githubusercontent.com/u/1502086?v=4)](https://github.com/kawax "kawax (654 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (62 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (56 commits)")[![puklipo](https://avatars.githubusercontent.com/u/88759954?v=4)](https://github.com/puklipo "puklipo (15 commits)")

---

Tags

copilot-clicopilot-sdklaravellaravelcopilot-clicopilot-sdk

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/revolution-laravel-copilot-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/revolution-laravel-copilot-sdk/health.svg)](https://phpackages.com/packages/revolution-laravel-copilot-sdk)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[ublabs/blade-simple-icons

A package to easily make use of Simple Icons in your Laravel Blade views.

1963.4k](/packages/ublabs-blade-simple-icons)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
