PHPackages                             elsayed85/copilot-ask-database - 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. [Database &amp; ORM](/categories/database)
4. /
5. elsayed85/copilot-ask-database

ActiveLibrary[Database &amp; ORM](/categories/database)

elsayed85/copilot-ask-database
==============================

Use Your Github Copilot To Answer Your Database Questions

12[2 PRs](https://github.com/elsayed85/copilot-ask-database/pulls)PHP

Since Sep 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/elsayed85/copilot-ask-database)[ Packagist](https://packagist.org/packages/elsayed85/copilot-ask-database)[ RSS](/packages/elsayed85-copilot-ask-database/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Laravel Copilot Database Assistant
==================================

[](#laravel-copilot-database-assistant)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1df90c9150a90d0daae5b1bb64ba41b1292ee5d6a746a255bb968765c864e859/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c736179656438352f636f70696c6f742d61736b2d64617461626173652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elsayed85/copilot-ask-database)[![GitHub Tests Action Status](https://camo.githubusercontent.com/06fe8372bfdab8fe6e4ae2cc5e3a2b6d7940d88b01fff0d3468e16ce44704d61/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656c736179656438352f636f70696c6f742d61736b2d64617461626173652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/elsayed85/copilot-ask-database/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/402b30cfc81bae132072347690c3b32cde5f956af0bc4ef9168a781a45cc4ddb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f656c736179656438352f636f70696c6f742d61736b2d64617461626173652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/elsayed85/copilot-ask-database/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/00d0b013a5b2fe9292e8850f1d4e682eb6274d6afd960dc5e171d3aa94c7c7c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c736179656438352f636f70696c6f742d61736b2d64617461626173652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elsayed85/copilot-ask-database)

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

[](#installation)

You can install the package via composer:

```
composer require elsayed85/copilot-ask-database "dev-master"
```

You can publish the config file with:

```
php artisan vendor:publish --tag="copilot-ask-database-config"
```

This is the contents of the published config file:

```
return [
    'github_token' => env('COPILOT_ASK_GITHUB_TOKEN'),

    /**
     * The database connection name to use. Depending on your
     * use case, you might want to limit the database user
     * to have read-only access to the database.
     */
    'connection' => env('COPILOT_ASK_CONNECTION', 'mysql'),

    /**
     * Strict mode will throw an exception when the query
     * would perform a write/alter operation on the database.
     *
     * If you want to allow write operations - or if you are using a read-only
     * database user - you may disable strict mode.
     */
    'strict_mode' => env('COPILOT_ASK_STRICT_MODE', true),

    /**
     * The maximum number of tables to use before performing an additional
     * table name lookup call to OpenAI.
     * If you have a lot of database tables and columns, they might not fit
     * into a single request to OpenAI. In that case, we will perform a
     * lookup call to OpenAI to get the matching table names for the
     * provided question.
     */
    'max_tables_before_performing_lookup' => env('COPILOT_ASK_MAXIMUM_TABLES', 15),

    'copilot' => [
        'intent' => false,
        'model' => 'copilot-chat', // Don't change this
        'top_p' => 1,
        'n' => 1,

        'client_id' => '01ab8ac9400c4e429b23', // Don't change this
        'user_agent' => 'GithubCopilot/3.99.99', // Don't change this
    ],
];
```

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="copilot-ask-database-views"
```

Views Contains Prompts templates , you can customize it as you want.

Setup Github Copilot
--------------------

[](#setup-github-copilot)

1. Authenticate with Github Copilot using code :

```
php artisan copilot:github:auth
```

```
Please visit the following URL and login with your Github account:
https://github.com/login/device
Please enter the following code in the Github Device Activation page:
Your Github auth code is: 0EFA-6762

```

2. Verify Github Copilot Authentication (After you login with your Github account and enter the code)

```
php artisan copilot:github:verify
```

```
Your Github access token is: gho_6E8rRBDL.........................
Please add the following line to your .env file:
COPILOT_ASK_GITHUB_TOKEN=gho_6E8rRBDL.........................

```

3. Add Github Copilot Token to your .env file

```
COPILOT_ASK_GITHUB_TOKEN=gho_6E8rRBDL.........................
```

Usage
-----

[](#usage)

### Ask For SQL Query

[](#ask-for-sql-query)

```
use Illuminate\Support\Facades\DB;

$question = 'How many users are there?';

$query = DB::askCopilotForQuery($question);
```

Answer

```
SELECT COUNT(*) FROM users
```

### Ask For Human Answer

[](#ask-for-human-answer)

```
use Illuminate\Support\Facades\DB;

$question = 'How many users are there?';

$query = DB::askCopilot($question);
```

Answer

```
There are 10 users.

```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Elsayed Kamal](https://github.com/elsayed85)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/9f6465ef2e90074d5a323bf893bb1ab9a7b5af7bf61d1001f85a8448d8fb257d?d=identicon)[elsayed851999](/maintainers/elsayed851999)

---

Top Contributors

[![elsayed85](https://avatars.githubusercontent.com/u/41492621?v=4)](https://github.com/elsayed85 "elsayed85 (3 commits)")

### Embed Badge

![Health badge](/badges/elsayed85-copilot-ask-database/health.svg)

```
[![Health](https://phpackages.com/badges/elsayed85-copilot-ask-database/health.svg)](https://phpackages.com/packages/elsayed85-copilot-ask-database)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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