PHP code example of larasofthu / laravel-guardian

1. Go to this page and download the library: Download larasofthu/laravel-guardian library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

larasofthu / laravel-guardian example snippets


use Illuminate\Support\Facades\Schedule;

Schedule::command('file-integrity:scan')->hourly();

protected function schedule(Schedule $schedule): void
{
    $schedule->command('file-integrity:scan')->hourly();
}
bash
php artisan vendor:publish --tag="file-integrity-config"
bash
php artisan vendor:publish --tag="file-integrity-views"
bash
php artisan file-integrity:scan
bash
php artisan file-integrity:scan --json
bash
php artisan file-integrity:scan --disks=local --disks=uploads
json
{
  "base_ref": "origin/main",
  "changed_files": {
    "added": ["config/new.php"],
    "modified": ["app/Models/User.php"],
    "deleted": ["old/file.php"],
    "renamed": [{"from": "old.php", "to": "new.php"}],
    "untracked": ["app/NewFile.php"]
  },
  "summary": {
    "total": 5,
    "added": 1,
    "modified": 1,
    "deleted": 1,
    "renamed": 1,
    "untracked": 1
  },
  "has_changes": true,
  "disk_scan": {
    "disks": ["local", "uploads", "public"],
    "findings": {
      "suspicious_php": [{"disk": "uploads", "file": "shell.php", "functions": ["eval"]}],
      "malware_patterns": [],
      "dangerous_files": [{"disk": "uploads", "file": "payload.exe", "extension": "exe"}],
      "suspicious_paths": [{"disk": "public", "file": "wp-admin/index.php", "pattern": "wp-admin"}]
    },
    "summary": {
      "suspicious_php_count": 1,
      "malware_patterns_count": 0,
      "dangerous_files_count": 1,
      "suspicious_paths_count": 1
    },
    "has_findings": true
  },
  "exit_code": 1
}