Skip to content

Installation

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

πŸ“¦ Installation Guide

Laravel Safeguard is a powerful security auditing package for Laravel applications. Follow this guide to get it installed and configured in your project.

πŸ”§ Requirements

  • PHP: 8.3 or higher
  • Laravel: 12.19 or higher

πŸ“₯ Installation via Composer

Install Laravel Safeguard using Composer:

composer require --dev grazulex/laravel-safeguard

πŸ’‘ Note: We recommend installing this as a development dependency since it's primarily used for auditing and CI/CD processes.

βš™οΈ Publishing Configuration

Publish the configuration file to customize the security rules:

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

This will create a config/safeguard.php file in your Laravel application with all available security rules.

βœ… Verification

Verify the installation by running:

php artisan safeguard:list

This should display all available security rules like:

πŸ›‘οΈ Available Security Rules:
───────────────────────────────────────

Environment & Configuration:
βœ“ app-debug-false-in-production
βœ“ env-has-all-required-keys
βœ“ app-key-is-set
βœ“ no-secrets-in-code

Security Rules:
βœ“ csrf-enabled
βœ“ composer-package-security
...

πŸš€ Basic Usage

Run your first security check:

php artisan safeguard:check

πŸ“š Next Steps

Now that you have Laravel Safeguard installed, here's what to do next:

πŸ—οΈ Installation in Different Environments

Laravel 12.x Projects

composer require --dev grazulex/laravel-safeguard
php artisan vendor:publish --tag=safeguard-config

Existing Projects with Custom Setup

For projects with complex setups, you may need additional configuration:

# Install the package
composer require --dev grazulex/laravel-safeguard

# Publish configuration
php artisan vendor:publish --tag=safeguard-config

# Clear caches to ensure proper loading
php artisan config:clear
php artisan cache:clear

Framework-Agnostic Usage

While primarily designed for Laravel, you can use the core security rules in any PHP project:

composer require grazulex/laravel-safeguard

Then manually configure the rules and services as needed.

πŸ†˜ Troubleshooting Installation

Composer Issues

If you encounter Composer issues:

# Clear Composer cache
composer clear-cache

# Update Composer
composer self-update

# Install with verbose output
composer require --dev grazulex/laravel-safeguard -vvv

Laravel Auto-Discovery

Laravel Safeguard uses package auto-discovery. If you need to manually register the service provider:

// config/app.php
'providers' => [
    // ...
    Grazulex\LaravelSafeguard\LaravelSafeguardServiceProvider::class,
],

Permission Issues

Ensure your storage directories are writable:

chmod -R 755 storage/
chmod -R 755 bootstrap/cache/

Configuration Cache Issues

If you're having issues with configuration caching:

php artisan config:clear
php artisan config:cache

πŸ”„ Updating Laravel Safeguard

To update to the latest version:

composer update grazulex/laravel-safeguard

After updating, republish the configuration if there are new options:

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

πŸ“‹ Installation Checklist

  • PHP 8.3+ installed
  • Laravel 12.19+ project
  • Package installed via Composer
  • Configuration published
  • Installation verified with safeguard:list
  • First security check run successfully

🀝 Need Help?

If you encounter any issues during installation:


Next Step: ⚑ Run your first security check with our Quick Start Guide

🏠 Home | ⚑ Quick Start | βš™οΈ Configuration | πŸ“ Rules Reference

Clone this wiki locally