Skip to content

Output Formats

Jean-Marc Strauven edited this page Aug 1, 2025 · 1 revision

πŸ“Š Output Formats

Laravel Safeguard supports multiple output formats to meet different needs, from human-readable CLI output to machine-parseable formats for automation and integration.

🎨 Available Formats

CLI Format (Default)

Human-readable format with colors and icons, perfect for terminal usage.

php artisan safeguard:check
# or explicitly
php artisan safeguard:check --format=cli

Example Output:

πŸ” Laravel Safeguard Security Check
═══════════════════════════════════════

Environment: production

βœ… APP_KEY is set
βœ… CSRF protection enabled
❌ APP_DEBUG is enabled in production
⚠️  Database connection not encrypted

═══════════════════════════════════════
🎯 2 issues found, 2 checks passed

JSON Format

Machine-readable format ideal for automation, CI/CD, and integrations.

php artisan safeguard:check --format=json

Example Output:

{
  "status": "failed",
  "environment": "production",
  "timestamp": "2025-01-01T10:00:00Z",
  "checks": [
    {
      "rule": "app-key-is-set",
      "status": "passed",
      "severity": "critical",
      "message": "APP_KEY is properly set"
    },
    {
      "rule": "app-debug-false-in-production",
      "status": "failed",
      "severity": "critical",
      "message": "APP_DEBUG is enabled in production",
      "recommendations": ["Set APP_DEBUG=false in production .env file"]
    }
  ],
  "summary": {
    "total": 10,
    "passed": 8,
    "failed": 1,
    "warnings": 1
  }
}

CI Format

Clean format without colors, optimized for CI/CD environments.

php artisan safeguard:check --format=ci

Example Output:

Laravel Safeguard Security Check
Environment: production

[PASS] APP_KEY is set
[PASS] CSRF protection enabled
[FAIL] APP_DEBUG is enabled in production
[WARN] Database connection not encrypted

2 issues found, 2 checks passed

HTML Format

Rich HTML format for reports and documentation.

php artisan safeguard:check --format=html > security-report.html

Features:

  • Interactive report with collapsible sections
  • Color-coded results
  • Detailed recommendations
  • Summary statistics
  • Responsive design

JUnit XML Format

Compatible with test reporting systems.

php artisan safeguard:check --format=junit > security-results.xml

Example Output:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Laravel Safeguard Security Check" tests="4" failures="1" time="0.5">
  <testsuite name="Security Rules" tests="4" failures="1" time="0.5">
    <testcase name="app-key-is-set" classname="Security" time="0.1"/>
    <testcase name="app-debug-false-in-production" classname="Security" time="0.1">
      <failure message="APP_DEBUG is enabled in production"/>
    </testcase>
  </testsuite>
</testsuites>

πŸ”§ Usage Examples

Development Workflow

# Quick check during development
php artisan safeguard:check

# Detailed check with recommendations
php artisan safeguard:check --verbose

CI/CD Integration

# GitHub Actions / GitLab CI
php artisan safeguard:check --format=ci --fail-on-error

# Generate JSON report for processing
php artisan safeguard:check --format=json > security-report.json

# JUnit format for test integration
php artisan safeguard:check --format=junit > security-results.xml

Reporting

# Generate HTML report
php artisan safeguard:check --format=html > reports/security-report.html

# Generate multiple formats
php artisan safeguard:check --format=json > security.json
php artisan safeguard:check --format=html > security.html
php artisan safeguard:check --format=ci > security.txt

πŸ“š Related Documentation


🏠 Home | πŸ”§ Commands | πŸš€ CI/CD Integration | πŸ’‘ Examples

Clone this wiki locally