spatie/laravel-csp
Easily add Content Security Policy (CSP) headers to your Laravel app. Define and enforce CSP directives, report violations, and tighten what scripts, styles, and other resources can load or connect to—helping mitigate XSS and malicious third‑party code.
Architecture fit: This package is purpose-built for Laravel's ecosystem, leveraging middleware, service container, and config patterns natively. It integrates seamlessly with Laravel's request lifecycle without architectural changes, using standard Laravel patterns for configuration and middleware registration.
Integration feasibility: Installation is trivial via Composer with clear publish commands for config and middleware. The package includes robust CI/CD (tests, code style checks), indicating high reliability. However, the "Last release: 2026-02-21" date appears erroneous (future-dated), which raises questions about release data accuracy despite active GitHub workflows.
Technical risk: CSP misconfiguration can silently break site functionality (e.g., blocking critical scripts). The report-only mode mitigates this risk during testing. Key concerns include nonce handling for dynamic content, potential conflicts with other security middleware, and the "Dependents: 0" metric (though likely inaccurate given 849 stars). The package's "unsafe-inline" handling requires careful validation.
Key questions:
Stack fit: Perfect alignment with Laravel's stack. Uses standard middleware
How can I help you explore Laravel packages today?