PHPackages                             protect/sql-query-protection - 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. [Security](/categories/security)
4. /
5. protect/sql-query-protection

ActiveLibrary[Security](/categories/security)

protect/sql-query-protection
============================

A Laravel middleware for SQL and XSS protection

v6.0.0(1y ago)9251MITPHPPHP ^7.4 || ^8.0

Since Oct 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/aswinsasi/injection-protector)[ Packagist](https://packagist.org/packages/protect/sql-query-protection)[ RSS](/packages/protect-sql-query-protection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (16)Used By (0)

---

**SQL and LDAP Query Protection Middleware for Laravel**
========================================================

[](#sql-and-ldap-query-protection-middleware-for-laravel)

This package provides **middleware** for Laravel applications to prevent **SQL injection** and **LDAP injection** attacks. It ensures secure communication by blocking malicious queries, protecting both your **database** and **directory services**.

---

**Features**
------------

[](#features)

- **SQL Injection Protection:**
    Validates and sanitizes SQL queries to prevent unauthorized access.
- **LDAP Injection Protection:**
    Prevents malicious LDAP queries by sanitizing input before querying directory services.
- **Custom Logging:**
    Logs suspicious queries for monitoring and further analysis.
- **Easy to Configure:**
    Configurable middleware with options for logging and handling injection attempts.

---

**Installation**
----------------

[](#installation)

You can install the package via **Composer**.

### **1. Require the Package**

[](#1-require-the-package)

```
composer require protect/sql-query-protection
```

Alternatively, you can install the latest development version:

```
composer require protect/sql-query-protection:@dev
```

### **2. Publish the Configuration File**

[](#2-publish-the-configuration-file)

```
php artisan vendor:publish --provider="SqlQueryProtection\SqlQueryProtectionServiceProvider"
```

### **3. Clear Config Cache**

[](#3-clear-config-cache)

After publishing the configuration, clear the config cache:

```
php artisan config:clear
```

---

Route Middleware Registration If you prefer to apply the middleware to specific routes, add the following line to the $routeMiddleware array:

```
protected $routeMiddleware = [
    // Other route middleware...
    'sql.protection' => \SqlQueryProtection\Middleware\SqlQueryProtection::class,
];
```

You can then use the middleware in your routes like this:

```
Route::middleware(['sql.protection'])->group(function () {
    Route::get('/your-route', 'YourController@yourMethod');
});
```

---

---

**Usage: SQL Protection Command**
---------------------------------

[](#usage-sql-protection-command)

This package provides an **Artisan command** to scan your routes for SQL injection vulnerabilities.

### **Command Syntax**

[](#command-syntax)

```
php artisan sqlprotection:scan
```

### **Sample Output:**

[](#sample-output)

```
Running SQL Protection Scan...
Checking route: api/users
Checking route: api/orders

No SQL injection vulnerabilities detected.

```

If vulnerabilities are detected, they will be listed as follows:

```
Potential SQL injection vulnerabilities found in the following routes:
- api/orders

```

---

**Configuration Options**
-------------------------

[](#configuration-options)

The configuration file is located at `config/sqlqueryprotection.php`. You can adjust the following settings:

```
return [
    'sql_protection_enabled' => true,
    'xss_protection_enabled' => true,
];
```

- **`sql_protection_enabled`**: Enables/Disables SQL injection protection.
- **`xss_protection_enabled`**: Enables/Disables XSS protection.

---

**Troubleshooting**
-------------------

[](#troubleshooting)

If the `sqlprotection:scan` command is not recognized or the package does not function as expected, follow these steps:

1. **Ensure the Service Provider is Registered:**
    Confirm the service provider is registered in `config/app.php`:

    ```
    'providers' => [
        SqlQueryProtection\SqlQueryProtectionServiceProvider::class,
    ],
    ```
2. **Run `composer dump-autoload`:**

    ```
    composer dump-autoload
    ```
3. **Clear Application Cache:**

    ```
    php artisan cache:clear
    php artisan config:clear
    ```

---

This **README** provides all the necessary steps to install, configure, and use the package effectively, including details about the **Artisan command** and **configuration options**.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~0 days

Total

15

Last Release

581d ago

Major Versions

v1.2.0 → v2.0.02024-10-13

v2.0.0 → v3.0.02024-10-15

v3.0.5 → v4.0.02024-10-15

v4.0.2 → v5.0.02024-10-15

v5.0.0 → v6.0.02024-10-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/60515ecdaad77bfafd15ba75eb885d307415b566d0ba759c9cc3df4bbf0e0927?d=identicon)[aswinsasi](/maintainers/aswinsasi)

---

Top Contributors

[![aswinsasi](https://avatars.githubusercontent.com/u/30518849?v=4)](https://github.com/aswinsasi "aswinsasi (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/protect-sql-query-protection/health.svg)

```
[![Health](https://phpackages.com/badges/protect-sql-query-protection/health.svg)](https://phpackages.com/packages/protect-sql-query-protection)
```

###  Alternatives

[illuminate/encryption

The Illuminate Encryption package.

9229.7M280](/packages/illuminate-encryption)[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

241641.4k1](/packages/tzsk-otp)[genealabs/laravel-governor

Managing policy and control in Laravel.

201262.8k](/packages/genealabs-laravel-governor)[dgtlss/warden

A Laravel package that proactively monitors your dependencies for security vulnerabilities by running automated composer audits and sending notifications via webhooks and email

8745.6k](/packages/dgtlss-warden)[ercsctt/laravel-file-encryption

Secure file encryption and decryption for Laravel applications

642.6k](/packages/ercsctt-laravel-file-encryption)[laragear/poke

Keep your forms alive, avoid TokenMismatchException by gently poking your Laravel app

2211.5k](/packages/laragear-poke)

PHPackages © 2026

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