PHPackages                             grazulex/laravel-safeguard - 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. grazulex/laravel-safeguard

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

grazulex/laravel-safeguard
==========================

Configurable security checks for Laravel applications. Run safety audits on environment variables, configuration files, and hidden routes to prevent common mistakes before going live.

v1.3.0(9mo ago)1313MITPHPPHP ^8.3CI passing

Since Jul 18Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/Grazulex/laravel-safeguard)[ Packagist](https://packagist.org/packages/grazulex/laravel-safeguard)[ Docs](https://github.com/grazulex/laravel-safeguard)[ RSS](/packages/grazulex-laravel-safeguard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (11)Versions (3)Used By (0)

Laravel Safeguard
=================

[](#laravel-safeguard)

[![Laravel Safeguard](new_logo.png)](new_logo.png)

Comprehensive security auditing and threat detection system for Laravel applications. Real-time monitoring, automated security assessments, and detailed security reporting.

[![Latest Version](https://camo.githubusercontent.com/a7cc8d6998ae20dd2198a5a7739a60edd174705c5eb9c65e63fe81e90b6ffeb4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6772617a756c65782f6c61726176656c2d7361666567756172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/grazulex/laravel-safeguard)[![Total Downloads](https://camo.githubusercontent.com/286e4bdfb2a9c0d2d7a834d00cda1567ce87cc7ec02de30838b0ba23ee1891cd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6772617a756c65782f6c61726176656c2d7361666567756172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/grazulex/laravel-safeguard)[![License](https://camo.githubusercontent.com/52b991549a4672f73ac39f3c4df900bc5033a3a8908b78e33077900856a45462/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6772617a756c65782f6c61726176656c2d7361666567756172642e7376673f7374796c653d666c61742d737175617265)](https://github.com/Grazulex/laravel-safeguard/blob/main/LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/a201d3fbf82702c7e84410563627084f973539d01771cf63a95870333bd21115/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6772617a756c65782f6c61726176656c2d7361666567756172642e7376673f7374796c653d666c61742d737175617265)](https://php.net/)[![Laravel Version](https://camo.githubusercontent.com/7592d340e2de1142fa869382b819654d6a0bf7baf8e3c8aded777d652d68c01a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31322e782d6666326432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://laravel.com/)[![Tests](https://camo.githubusercontent.com/68dc2638fae8d8ae40a7373e61f9930f2491968f3b18bb0f841660c6b233cffd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6772617a756c65782f6c61726176656c2d7361666567756172642f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/Grazulex/laravel-safeguard/actions)[![Code Style](https://camo.githubusercontent.com/161d70e6871f808e0439b3e7a86540993ae98775540b5a2e78226000e3c419c7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d70696e742d3030303030303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://github.com/laravel/pint)

📖 Table of Contents
-------------------

[](#-table-of-contents)

- [Overview](#overview)
- [✨ Features](#-features)
- [📦 Installation](#-installation)
- [🚀 Quick Start](#-quick-start)
- [🔒 Security Auditing](#-security-auditing)
- [🚨 Threat Detection](#-threat-detection)
- [📊 Security Dashboard](#-security-dashboard)
- [⚙️ Configuration](#%EF%B8%8F-configuration)
- [📚 Documentation](#-documentation)
- [💡 Examples](#-examples)
- [🧪 Testing](#-testing)
- [🔧 Requirements](#-requirements)
- [🚀 Performance](#-performance)
- [🤝 Contributing](#-contributing)
- [🔒 Security](#-security)
- [📄 License](#-license)

Overview
--------

[](#overview)

Laravel Safeguard is a comprehensive security auditing and threat detection system for Laravel applications. It provides real-time monitoring, automated security assessments, and detailed reporting to keep your application secure.

**Perfect for enterprise applications, security-conscious projects, and applications requiring compliance with security standards.**

### 🎯 Use Cases

[](#-use-cases)

Laravel Safeguard is perfect for:

- **Enterprise Applications** - Comprehensive security monitoring
- **Financial Systems** - Fraud detection and prevention
- **Healthcare Apps** - HIPAA compliance and data protection
- **E-commerce** - Transaction security and user protection
- **API Security** - Rate limiting and abuse detection

✨ Features
----------

[](#-features)

- 🚀 **Real-time Monitoring** - Live security event tracking and alerting
- 🔍 **Vulnerability Scanning** - Automated security vulnerability detection
- 🛡️ **Intrusion Detection** - Advanced threat detection algorithms
- 📊 **Security Dashboard** - Comprehensive security metrics and reporting
- 🚨 **Alert System** - Configurable alerts for security events
- 🔐 **Access Control** - Role-based access control monitoring
- 📋 **Audit Logging** - Detailed security event logging
- 🎯 **Rate Limiting** - Advanced rate limiting with threat intelligence
- ✅ **Compliance Reporting** - Generate compliance reports
- 📈 **Security Analytics** - Deep security insights and trends
- 🧪 **Penetration Testing** - Built-in security testing tools
- ⚡ **Performance Optimized** - Minimal impact on application performance

📦 Installation
--------------

[](#-installation)

Install the package via Composer:

```
composer require grazulex/laravel-safeguard
```

> **💡 Auto-Discovery**
> The service provider will be automatically registered thanks to Laravel's package auto-discovery.

Publish configuration:

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

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Initialize Safeguard

[](#1-initialize-safeguard)

```
php artisan safeguard:install
```

### 2. Configure Security Rules

[](#2-configure-security-rules)

```
// config/safeguard.php
return [
    'threat_detection' => [
        'enabled' => true,
        'sql_injection' => true,
        'xss_protection' => true,
        'brute_force' => true,
    ],

    'rate_limiting' => [
        'enabled' => true,
        'requests_per_minute' => 60,
        'burst_limit' => 100,
    ],

    'audit_logging' => [
        'enabled' => true,
        'log_failed_logins' => true,
        'log_data_access' => true,
    ],
];
```

### 3. Add Middleware Protection

[](#3-add-middleware-protection)

```
// app/Http/Kernel.php
protected $middleware = [
    \Grazulex\LaravelSafeguard\Middleware\SecurityMonitor::class,
    \Grazulex\LaravelSafeguard\Middleware\ThreatDetection::class,
];

protected $middlewareGroups = [
    'web' => [
        \Grazulex\LaravelSafeguard\Middleware\RateLimiter::class,
    ],
    'api' => [
        \Grazulex\LaravelSafeguard\Middleware\ApiProtection::class,
    ],
];
```

### 4. Monitor Security Events

[](#4-monitor-security-events)

```
use Grazulex\LaravelSafeguard\Facades\Safeguard;

// Get security dashboard data
$dashboard = Safeguard::dashboard();

// Check recent threats
$threats = Safeguard::getThreats(['last_24_hours' => true]);

// Generate security report
$report = Safeguard::generateReport('monthly');

// Get audit logs
$auditLogs = Safeguard::auditLogs()
    ->where('event_type', 'login_attempt')
    ->where('created_at', '>=', now()->subDays(7))
    ->get();
```

🔒 Security Auditing
-------------------

[](#-security-auditing)

Laravel Safeguard provides comprehensive security auditing:

```
// Enable automatic auditing
Safeguard::audit(User::class)->track([
    'created', 'updated', 'deleted',
    'login', 'logout', 'password_change'
]);

// Manual audit logging
Safeguard::log('user_data_access', [
    'user_id' => auth()->id(),
    'accessed_resource' => 'sensitive_data',
    'ip_address' => request()->ip(),
]);

// Security scanning
$vulnerabilities = Safeguard::scan([
    'sql_injection' => true,
    'xss_vulnerabilities' => true,
    'csrf_protection' => true,
    'security_headers' => true,
]);
```

🚨 Threat Detection
------------------

[](#-threat-detection)

Advanced threat detection capabilities:

```
use Grazulex\LaravelSafeguard\ThreatDetection\Detectors;

// Configure threat detectors
Safeguard::threats()->register([
    Detectors\SqlInjectionDetector::class,
    Detectors\XssDetector::class,
    Detectors\BruteForceDetector::class,
    Detectors\SuspiciousActivityDetector::class,
]);

// Real-time threat monitoring
Safeguard::threats()->monitor(function ($threat) {
    // Log threat
    Log::warning('Security threat detected', [
        'type' => $threat->getType(),
        'severity' => $threat->getSeverity(),
        'details' => $threat->getDetails(),
    ]);

    // Send alert
    if ($threat->getSeverity() === 'high') {
        Mail::to('security@company.com')->send(
            new SecurityAlert($threat)
        );
    }
});
```

📊 Security Dashboard
--------------------

[](#-security-dashboard)

Built-in security dashboard with comprehensive metrics:

```
// Access dashboard data
$dashboard = Safeguard::dashboard()->getData();

// Dashboard metrics include:
// - Threat detection statistics
// - Failed login attempts
// - Rate limiting statistics
// - Vulnerability scan results
// - Audit log summaries
// - Security score and trends

// Custom dashboard widgets
Safeguard::dashboard()->addWidget('custom_security_metric', function () {
    return [
        'title' => 'Custom Security Metric',
        'value' => $this->calculateCustomMetric(),
        'trend' => 'up',
        'color' => 'green',
    ];
});
```

⚙️ Configuration
----------------

[](#️-configuration)

Laravel Safeguard provides extensive configuration options:

```
// config/safeguard.php
return [
    'monitoring' => [
        'enabled' => true,
        'real_time_alerts' => true,
        'threat_intelligence' => true,
    ],

    'detection_rules' => [
        'sql_injection' => ['enabled' => true, 'sensitivity' => 'high'],
        'xss_protection' => ['enabled' => true, 'sanitize' => true],
        'brute_force' => ['enabled' => true, 'max_attempts' => 5],
    ],

    'compliance' => [
        'gdpr' => true,
        'hipaa' => false,
        'pci_dss' => true,
    ],
];
```

📚 Documentation
---------------

[](#-documentation)

For detailed documentation, examples, and advanced usage:

- 📚 [Full Documentation](https://github.com/Grazulex/laravel-safeguard/wiki)
- 🎯 [Examples](https://github.com/Grazulex/laravel-safeguard/wiki/Examples)
- 🔧 [Configuration](https://github.com/Grazulex/laravel-safeguard/wiki/Configuration)
- 🧪 [Testing](https://github.com/Grazulex/laravel-safeguard/wiki/Testing)
- 🚨 [Threat Detection](https://github.com/Grazulex/laravel-safeguard/wiki/Threat-Detection)

💡 Examples
----------

[](#-examples)

### Basic Security Monitoring

[](#basic-security-monitoring)

```
use Grazulex\LaravelSafeguard\Facades\Safeguard;

// Enable monitoring for specific models
class User extends Model
{
    use \Grazulex\LaravelSafeguard\Traits\Auditable;

    protected $auditableEvents = ['created', 'updated', 'login'];
}

// Monitor API endpoints
Route::middleware(['safeguard.monitor'])->group(function () {
    Route::get('/api/sensitive-data', [ApiController::class, 'getData']);
});

// Custom threat detection
Safeguard::threats()->detect('custom_threat', function ($request) {
    return $request->has('suspicious_parameter');
});
```

### Advanced Security Configuration

[](#advanced-security-configuration)

```
// Custom security rules
Safeguard::rules()->add('financial_transaction', [
    'min_amount' => 0.01,
    'max_amount' => 10000,
    'require_2fa' => true,
    'suspicious_patterns' => [
        'rapid_succession' => true,
        'unusual_amounts' => true,
    ],
]);

// Security event handling
Safeguard::events()->listen('threat_detected', function ($threat) {
    // Automatically block suspicious IPs
    if ($threat->getSeverity() === 'critical') {
        Safeguard::firewall()->block($threat->getIpAddress());
    }
});
```

Check out the [examples on the wiki](https://github.com/Grazulex/laravel-safeguard/wiki/Examples) for more examples.

🧪 Testing
---------

[](#-testing)

Laravel Safeguard includes security testing utilities:

```
use Grazulex\LaravelSafeguard\Testing\SecurityTester;

public function test_sql_injection_protection()
{
    SecurityTester::make()
        ->attemptSqlInjection('/api/users?id=1; DROP TABLE users;--')
        ->assertBlocked()
        ->assertThreatLogged('sql_injection');
}

public function test_rate_limiting()
{
    SecurityTester::make()
        ->simulateRequests('/api/endpoint', 100)
        ->assertRateLimited()
        ->assertAuditLogged();
}
```

🔧 Requirements
--------------

[](#-requirements)

- PHP: ^8.3
- Laravel: ^12.0
- Carbon: ^3.10

🚀 Performance
-------------

[](#-performance)

Laravel Safeguard is optimized for performance:

- **Minimal Overhead**: Less than 2ms additional request time
- **Efficient Monitoring**: Asynchronous threat detection
- **Caching**: Security rules and patterns are cached
- **Database Optimized**: Efficient audit log storage

🤝 Contributing
--------------

[](#-contributing)

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.

🔒 Security
----------

[](#-security)

If you discover a security vulnerability, please review our [Security Policy](SECURITY.md) before disclosing it.

📄 License
---------

[](#-license)

Laravel Safeguard is open-sourced software licensed under the [MIT license](LICENSE.md).

---

**Made with ❤️ for the Laravel community**

### Resources

[](#resources)

- [📖 Documentation](https://github.com/Grazulex/laravel-safeguard/wiki)
- [💬 Discussions](https://github.com/Grazulex/laravel-safeguard/discussions)
- [🐛 Issue Tracker](https://github.com/Grazulex/laravel-safeguard/issues)
- [📦 Packagist](https://packagist.org/packages/grazulex/laravel-safeguard)

### Community Links

[](#community-links)

- [CODE\_OF\_CONDUCT.md](CODE_OF_CONDUCT.md) - Our code of conduct
- [CONTRIBUTING.md](CONTRIBUTING.md) - How to contribute
- [SECURITY.md](SECURITY.md) - Security policy
- [RELEASES.md](RELEASES.md) - Release notes and changelog

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance57

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

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

2

Last Release

297d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/888105bd54b6b7f7905523a16a1d08eebc2e5d39b19a4c174b5961bb4d52929b?d=identicon)[Grazulex](/maintainers/Grazulex)

---

Top Contributors

[![Grazulex](https://avatars.githubusercontent.com/u/4521546?v=4)](https://github.com/Grazulex "Grazulex (44 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (18 commits)")

---

Tags

laravelpackagephpsecurityclilaravelcheckconfigsecurityenvAuditsecurerulesclean codeproductionlaravel12php8.3hardeningsafeguard

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/grazulex-laravel-safeguard/health.svg)

```
[![Health](https://phpackages.com/badges/grazulex-laravel-safeguard/health.svg)](https://phpackages.com/packages/grazulex-laravel-safeguard)
```

###  Alternatives

[alajusticia/laravel-logins

Session management in Laravel apps, user notifications on new access, support for multiple separate remember tokens, IP geolocation, User-Agent parser

2011.0k](/packages/alajusticia-laravel-logins)[lowerends/laravel-security-checker

The Symfony Security Advisories Checker for Laravel

301.5k](/packages/lowerends-laravel-security-checker)[grazulex/laravel-atlas

Laravel Atlas scans your Laravel project to generate a complete, structured map of its internal components — models, controllers, routes, jobs, observers, events, commands, and more — and exports visual or machine-readable representations in formats like Mermaid, Markdown, JSON, or PDF.

161.7k](/packages/grazulex-laravel-atlas)

PHPackages © 2026

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