PHPackages                             pragmarx/sqli - 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. pragmarx/sqli

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

pragmarx/sqli
=============

A Laravel Artisan SQL Interactive Interface

v1.0.1(11y ago)601.9k5[2 issues](https://github.com/antonioribeiro/sqli/issues)BSD-3-ClausePHPPHP &gt;=5.3.7

Since Mar 29Pushed 7y ago2 watchersCompare

[ Source](https://github.com/antonioribeiro/sqli)[ Packagist](https://packagist.org/packages/pragmarx/sqli)[ RSS](/packages/pragmarx-sqli/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (4)Versions (7)Used By (0)

sqli
====

[](#sqli)

[![Latest Stable Version](https://camo.githubusercontent.com/21037dd83c93945edf81bbb0140f9b324f25c3e0cea36a683be2cdc7bffd95d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f707261676d6172782f73716c692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pragmarx/sqli) [![License](https://camo.githubusercontent.com/a7d953c880516e66cbc40f3833498c010255e60ca0142114a22829dc66fe28e4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4253445f335f436c617573652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE) [![Downloads](https://camo.githubusercontent.com/38846e616d84c9f5a0c5f148edb9b833b0eb77da8f44c63f784846753d5e3291/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f707261676d6172782f73716c692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pragmarx/sqli)

A Laravel 4 &amp; 5 Artisan SQL Interactive Interface, plus a handful of Artisan commands to execute SQL queries.

sqli
----

[](#sqli-1)

It's like tinker for SQL, just run

```
php artisan sqli

```

And execute whatever sql query you like in your sql:

```
postgresql:laravel> select email from users;

```

And you should see it this way:

```
+----+------------------------------+
| id | email                        |
+----+------------------------------+
|  1 | arnold@schwarzenegger.com    |
|  2 | danny@devito.com             |
+----+------------------------------+
Executed in 0.0602 seconds.

```

You can get a list of your tables by running:

```
postgresql:laravel> tables count

```

`count` option is optional:

```
+--------------+-----------------------------+-----------+
| table_schema | table_name                  | row_count |
+--------------+-----------------------------+-----------+
| public       | firewall                    | 2         |
| public       | migrations                  | 3         |
| public       | sessions                    | 1         |
| public       | users                       | 1         |
| public       | actors                      | 3431326   |
| public       | movies                      | 1764727   |
+--------------+-----------------------------+-----------+

```

You can view a list of databases:

```
postgresql:laravel> databases

+-----------------+--------+--------------------------+-----------+
| Connection Name | Driver | Database                 | Host      |
+-----------------+--------+--------------------------+-----------+
| postgres        | pgsql  | production               | localhost |
| tracker         | mysql  | tracker                  | localhost |
+-----------------+--------+--------------------------+-----------+

```

You can change your current database connection by:

```
postgresql:laravel> database mysql
mysql:staging>

```

You can list all commands by executing

```
postgresql:laravel> help

+----------+------------------------------------------------------------------------------+
| command  | description                                                                  |
+----------+------------------------------------------------------------------------------+
| quit     | Exit interface.                                                              |
| tables   | List all tables. Use "tables count" to list with row count.                  |
| help     | Show this help.                                                              |
| database | Change the current database connection. Usage: "database [connection name]". |
+----------+------------------------------------------------------------------------------+

```

To exit, just type `CTRL-C`, `CTRL-D` or `quit`.

Other Artisan Commands
----------------------

[](#other-artisan-commands)

You don't need to enter sqli to execute commands, you have access to the most common DML commands via direct Artisan commands:

```
select
insert
update
delete

```

A special DML command, to execute whatever else you may needd:

```
sql

```

And a command for listing tables:

```
tables

```

Syntax
------

[](#syntax)

The syntax could not be simpler, just execute

```
php artisan select email, first_name, last_name from users

```

And you should get a result like:

```
+----+------------------------------+----------------+----------------+
| id | email                        | first_name     | last_name      |
+----+------------------------------+----------------+----------------+
|  1 | arnold@schwarzenegger.com    | Arnold         | Schwarzenegger |
|  2 | danny@devito.com             | Danny          | DeVito         |
+----+------------------------------+----------------+----------------+

```

Create a very small alias for Artisan:

```
alias a='php artisan'

```

And it'll be as if you where in your sql interface:

```
a select * from posts where post_id < 100

a update posts set author_id = 1

a delete from posts

a sql call removeOldPosts()

```

Command 'table'
---------------

[](#command-table)

The command

```
php artisan tables --count

```

Will give you a list of your tables with an optional row count:

```
+--------------+-----------------------------+-----------+
| table_schema | table_name                  | row_count |
+--------------+-----------------------------+-----------+
| public       | firewall                    | 2         |
| public       | migrations                  | 3         |
| public       | sessions                    | 1         |
| public       | users                       | 1         |
| public       | actors                      | 3431326   |
| public       | movies                      | 1764727   |
+--------------+-----------------------------+-----------+

```

Too many columns aren't good to look at?
----------------------------------------

[](#too-many-columns-arent-good-to-look-at)

Use the `less` command to help you with that:

```
a select * from users | less -S

```

Should give you a scrollable view of your table:

```
+----+------------------------------+-------------+-----------+--------------------------------------------+---------------------+---------------------+--------------------------------------------------------------+---------------------+----------------+----------------+----------------------------+----------------------------+--------------------------------------------------------------+-----------+-------------+-----------+-----------+-------------+------------+--------------+------------------+-------------------+-----------------+-------------------+-----------------+-----------------+
| id | email                        | permissions | activated | activation_code                            | activated_at        | last_login          | persist_code                                                 | reset_password_code | first_name     | last_name      | created_at                 | updated_at                 | password                                                     | gender_id | middle_name | nick_name | birth_day | birth_month | birth_year | early_signup | imported_from_id | registration_time | registration_ip | registrated_by_id | activation_time | beta_invitation |
+----+------------------------------+-------------+-----------+--------------------------------------------+---------------------+---------------------+--------------------------------------------------------------+---------------------+----------------+----------------+----------------------------+----------------------------+--------------------------------------------------------------+-----------+-------------+-----------+-----------+-------------+------------+--------------+------------------+-------------------+-----------------+-------------------+-----------------+-----------------+
| 38 | arnold@schwarzenegger.com    |             | 1         | V38ScwjCORUvCpuhjkieR4KbnQSlVbhFHujmsyVvN8 | 2014-02-16 14:07:59 | 2014-03-27 18:59:56 | $2y$10$POQ18Kc5JXftOtJswQujBO0PAQ4cfqsSXLKckn9aZOM4VgaExRDHa |                     | Arnold         | Schwarzenegger | 2014-03-29 18:38:39.998522 | 2014-03-27 18:59:56        | $2y$10$5S3KaI6PPHnySECVRwRcferQdiJZP6QgX5adxK7z/WPlxP386HW0e |           |             |           | 31        | 10          |            |              |                  |                   |                 |                   |                 |                 |
| 40 | clint@eastwood.com           |             |           |                                            |                     |                     |                                                              |                     | Clint          | Eastwood       | 2014-03-29 18:38:39.998522 | 2014-03-29 18:26:17.402382 |                                                              |           |             |           |           |             |            |              |                  |                   |                 |                   |                 |                 |
| 41 | paul@newman.com              |             |           |                                            |                     |                     |                                                              |                     | Paul           | Newman         | 2014-03-29 18:38:39.998522 | 2014-03-29 18:32:22.489968 |                                                              |           |             |           |           |             |            |              |                  |                   |                 |                   |                 |                 |
+----+------------------------------+-------------+-----------+--------------------------------------------+---------------------+---------------------+--------------------------------------------------------------+---------------------+----------------+----------------+----------------------------+----------------------------+--------------------------------------------------------------+-----------+-------------+-----------+-----------+-------------+------------+--------------+------------------+-------------------+-----------------+-------------------+-----------------+-----------------+

```

Drawbacks
---------

[](#drawbacks)

When passing arguments to scripts Linux based systems may remove quotes and misunderstand your parentheses in queries, you if you need to use them you'll have to double quote it:

```
a insert "into users (email, first_name, last_name, created_at, updated_at) values ('clint@eastwood.com', 'Clint', 'Eastwood', 'NOW', 'NOW')"

```

or just the parts that have them:

```
a insert into users "(email, first_name, last_name, created_at, updated_at)" values "('clint@eastwood.com', 'Clint', 'Eastwood', 'NOW', 'NOW')"

```

But you can also escape them with \\

```
a update users set created_at = \'NOW\'

```

Command Line Completion
-----------------------

[](#command-line-completion)

All SQL commands, connections, tables names and columns are present in completion, just use TAB to complete your commands.

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

[](#installation)

### Requirements

[](#requirements)

- Laravel 4.1+ / Laravel 5+

### Installing

[](#installing)

Require the package using [Composer](https://getcomposer.org/):

```
composer require pragmarx/sqli

```

Add the service provider to your app/config/app.php:

```
'PragmaRX\Sqli\Vendor\Laravel\ServiceProvider',

```

Author
------

[](#author)

[Antonio Carlos Ribeiro](http://twitter.com/iantonioribeiro)

License
-------

[](#license)

sqli is licensed under the BSD 3-Clause License - see the `LICENSE` file for details

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

[](#contributing)

Pull requests and issues are more than welcome.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 97% 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 ~71 days

Recently: every ~88 days

Total

6

Last Release

4070d ago

Major Versions

v0.5.4 → v1.0.02015-03-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/d9421a69d192db597169ec3519ad3efc6a35a660e4525e2ed08f6c753b908e86?d=identicon)[AntonioCarlosRibeiro](/maintainers/AntonioCarlosRibeiro)

---

Top Contributors

[![antonioribeiro](https://avatars.githubusercontent.com/u/3182864?v=4)](https://github.com/antonioribeiro "antonioribeiro (65 commits)")[![angelorubin](https://avatars.githubusercontent.com/u/1530309?v=4)](https://github.com/angelorubin "angelorubin (1 commits)")[![zeyad82](https://avatars.githubusercontent.com/u/16030521?v=4)](https://github.com/zeyad82 "zeyad82 (1 commits)")

---

Tags

databaseslaravelphpsqlisqlitelaravelREPLsqlartisanquerysqli

### Embed Badge

![Health badge](/badges/pragmarx-sqli/health.svg)

```
[![Health](https://phpackages.com/badges/pragmarx-sqli/health.svg)](https://phpackages.com/packages/pragmarx-sqli)
```

###  Alternatives

[rennokki/laravel-eloquent-query-cache

Adding cache on your Laravel Eloquent queries' results is now a breeze.

1.1k4.0M14](/packages/rennokki-laravel-eloquent-query-cache)[sarfraznawaz2005/indexer

Laravel package to monitor SELECT queries and offer best possible INDEX fields.

562.7k](/packages/sarfraznawaz2005-indexer)

PHPackages © 2026

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