PHPackages                             ekramul/laravel-security-guard - 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. ekramul/laravel-security-guard

ActiveLibrary

ekramul/laravel-security-guard
==============================

Full Laravel security scanner with malware detection, quarantine &amp; dashboard

10PHP

Since Mar 28Pushed 1mo agoCompare

[ Source](https://github.com/developerekramul1/laravel-security-guard-upgraded)[ Packagist](https://packagist.org/packages/ekramul/laravel-security-guard)[ RSS](/packages/ekramul-laravel-security-guard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

??? Laravel Security Guard
==========================

[](#-laravel-security-guard)

> A production-ready security scanner for Laravel projects with automated malware detection, quarantine system, and admin dashboard.

[![Laravel](https://camo.githubusercontent.com/d07be99ec7b3642c4dcd857181fe8cbfd079222a50b3a2f9948797b3e45fb7ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392e302b2d7265643f7374796c653d666f722d7468652d6261646765266c6f676f3d6c61726176656c)](https://laravel.com)[![PHP](https://camo.githubusercontent.com/08eed0741c93af7b40e1c6a4bbe90878c65177df2eac27ee7a05cbbb69f5dbd1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302b2d626c75653f7374796c653d666f722d7468652d6261646765266c6f676f3d706870)](https://php.net)[![License](https://camo.githubusercontent.com/153acf9dff19deb8abfc598c53bac50a4ceae0f5c83a552711060d3d78d2c057/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e3f7374796c653d666f722d7468652d6261646765)](LICENSE)

---

?? Table of Contents
--------------------

[](#-table-of-contents)

- [Features](#features)
- [Quick Start](#quick-start)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Dashboard](#dashboard)
- [Advanced Customization](#advanced-customization)
- [Security Tips](#security-tips)

---

? Features
----------

[](#-features)

? **Automated Malware Scanning** - Detects malicious code patterns (eval(), base64\_decode(), shell\_exec(), etc.)
? **Auto Quarantine System** - Automatically isolates suspicious files
? **Email Alerts** - Real-time notifications to admin when threats are detected
? **Admin Dashboard** - Monitor all detections and quarantined files
? **Scheduled Scans** - Configure via Laravel scheduler for automatic checks
? **Database Logging** - Complete audit trail of all detections
? **Easy Restoration** - Recover files from quarantine if needed

---

?? Quick Start
--------------

[](#-quick-start)

\\\\�ash

1. Install the package
======================

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

composer require ekramul/laravel-security-guard

2. Run installation command
===========================

[](#2-run-installation-command)

php artisan security:install

3. Run migrations
=================

[](#3-run-migrations)

php artisan migrate

4. Scan your project
====================

[](#4-scan-your-project)

php artisan security:scan

5. View dashboard
=================

[](#5-view-dashboard)

Open:
===============================================

[](#open-httpyourapplocalsecuritydashboard)

\\\\

---

?? Installation
---------------

[](#-installation)

### Step 1: Composer Installation

[](#step-1-composer-installation)

\\\\�ash composer require ekramul/laravel-security-guard \\\\

The Service Provider will be automatically registered.

### Step 2: Publish Configuration &amp; Assets

[](#step-2-publish-configuration--assets)

\\\\�ash php artisan security:install \\\\

**What this does:**

- ?? Publishes \\config/security.php\\
- ?? Creates \\storage/quarantine/\\ folder
- ?? Sets up default scanners and email configurations

### Step 3: Run Database Migration

[](#step-3-run-database-migration)

\\\\�ash php artisan migrate \\\\

Creates the \\security\_logs\\ table:

ColumnTypeDescription\\id\\intAuto-increment primary key\\ile\_path\\stringOriginal file path that was flagged\\quarantined\_path\\stringPath in quarantine folder\\detected\_at\\timestampWhen malware was detected---

?? Configuration
----------------

[](#-configuration)

Edit \\config/security.php:

\\\\php return \[ 'email' =&gt; env('SECURITY\_EMAIL', env('MAIL\_FROM\_ADDRESS')), 'auto\_quarantine' =&gt; true, 'scan\_path' =&gt; base\_path(), \]; \\\\

### Configuration Options

[](#configuration-options)

OptionTypeDescription\\email\\stringAdmin email for security alerts\\�uto\_quarantine\\booleanAuto-move suspicious files (true/false)\\scan\_path\\stringDirectory to scan (default: entire project)### Examples

[](#examples)

\\\\php // Scan only the 'app' directory 'scan\_path' =&gt; base\_path('app'),

// Manual review mode (don't auto-quarantine) 'auto\_quarantine' =&gt; false,

// Custom admin email 'email' =&gt; '', \\\\

---

?? Usage
--------

[](#-usage)

### 1?? Manual Scan

[](#1-manual-scan)

\\\\�ash php artisan security:scan \\\\

**Output:**

- ? If clean � No malware detected
- ?? If threats found � Files are quarantined + email alert sent

### 2?? Automated Scheduled Scans

[](#2-automated-scheduled-scans)

Edit \\�pp/Console/Kernel.php:

\\\\php -&gt;command('security:scan')-&gt;daily(); \\\\

**Frequency Options:**

- -&gt;hourly()\\ - Every hour
- -&gt;daily()\\ - Every 24 hours (default)
- -&gt;weekly()\\ - Every week
- -&gt;twiceDaily()\\ - Twice per day

### 3?? Dashboard (Admin Panel)

[](#3-dashboard-admin-panel)

**Access:** \\[http://yourapp.local/security/dashboard\\](http://yourapp.local/security/dashboard%5C)

**Requirements:**

- Must be authenticated (Laravel auth middleware)
- Optional: Add role-check for admin-only access

**Dashboard Features:**

- ?? View all security logs
- ?? File path and detection date
- ?? Quarantined file locations
- ?? Paginate and filter results

### 4?? Email Alerts

[](#4-email-alerts)

Every detection triggers an email alert to your configured admin email.

**Customize Alert Template:**

\\\\php // In your mail class or notification Mail::send('emails.malware\_alert', \['file' =&gt; \], function() { -&gt;to('') -&gt;subject('?? Malware Detected on ' . config('app.name')); }); \\\\

### 5?? Quarantine &amp; Restoration

[](#5-quarantine--restoration)

**Restore a Quarantined File:**

\\\\php use Ekramul\\SecurityGuard\\Scanner\\Cleaner;

\\ = new Cleaner(); -&gt;restore( storage\_path('quarantine/suspicious-file.php'), base\_path('app/suspicious-file.php') ); \\\\

---

?? Dashboard
------------

[](#-dashboard)

The dashboard provides a centralized view of all security events:

\\
Security Dashboard ├── ?? Statistics (Total Threats, Status) ├── ?? Search &amp; Filter ├── ?? Quarantine Logs └── ? Quick Actions (Restore, Delete) \\\\

**Extend Dashboard Functionality:**

\\\\php // In DashboardController.php // Add filters by date, file type, status // Implement restore buttons // Export logs to CSV/PDF \\\\

---

?? Advanced Customization
-------------------------

[](#-advanced-customization)

### Add Custom Malware Patterns

[](#add-custom-malware-patterns)

Edit \\src/Scanner/MalwareScanner.php:

\\\\php protected \\ = \[ 'eval(', 'base64\_decode(', 'shell\_exec(', 'exec(', 'gzinflate(', 'system(', 'passthru(', // Add custom patterns 'proc\_open(', \]; \\\\

### Limit Scan to Specific Folders

[](#limit-scan-to-specific-folders)

\\\\php -&gt;scan(base\_path('app')); // Scan only app folder -&gt;scan(base\_path('app/Http')); // Even more specific \\\\

### Add Slack Notifications

[](#add-slack-notifications)

Extend \\ScanCommand.php:

\\\\php use Illuminate\\Notifications\\Notification;

Notification::route('slack', env('SLACK\_WEBHOOK\_URL')) -&gt;notify(new MalwareDetected()); \\\\

### Dashboard Enhancements

[](#dashboard-enhancements)

- ?? Add date range filters
- ??? Filter by file type (.php, .js, etc.)
- ?? Add statistics/charts
- ?? Export to CSV/PDF
- ?? Restore button for each file

---

??? Security Tips
-----------------

[](#-security-tips)

? **Quarantine Folder Protection**\\\\�ash

Make sure storage/quarantine is NOT publicly accessible
=======================================================

[](#make-sure-storagequarantine-is-not-publicly-accessible)

Configure your web server accordingly
=====================================

[](#configure-your-web-server-accordingly)

\\\\

? **Dashboard Access Control**\\\\php // Add role-based access in DashboardController if (!auth()-&gt;user()-&gt;isAdmin()) { abort(403); } \\\\

? **Best Practices**

- ?? Regularly monitor email alerts
- ?? Review dashboard logs weekly
- ?? Backup database regularly
- ?? Keep Laravel core updated
- ?? Use alongside Laravel backup package

---

?? Complete Workflow
--------------------

[](#-complete-workflow)

1. Install package via Composer
2. Run \\php artisan security:install\\
3. Run migrations: \\php artisan migrate\\
4. Check dashboard at /security/dashboard\\
5. Manually scan: \\php artisan security:scan\\
6. Monitor logs and email alerts
7. Restore files if needed from quarantine
8. Schedule automatic scans via cron

---

?? License
----------

[](#-license)

MIT License - Feel free to use in your projects!

---

**Made with ?? for Laravel developers**

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance60

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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/d70b00000fb097c181adb285a93f97bc3a3d232cc047ba25a0fdacb169d55e96?d=identicon)[developerEkramul](/maintainers/developerEkramul)

---

Top Contributors

[![developerekramul1](https://avatars.githubusercontent.com/u/124897495?v=4)](https://github.com/developerekramul1 "developerekramul1 (1 commits)")

### Embed Badge

![Health badge](/badges/ekramul-laravel-security-guard/health.svg)

```
[![Health](https://phpackages.com/badges/ekramul-laravel-security-guard/health.svg)](https://phpackages.com/packages/ekramul-laravel-security-guard)
```

PHPackages © 2026

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