1. Go to this page and download the library: Download bretto36/csp-reporting 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/ */
bretto36 / csp-reporting example snippets
'route' => [
'prefix' => 'csp-reporting', // Alter this to a different prefix
'middleware' => ['web'], // Change the middleware you want to use
],
use Bretto36\CspReporting\Events\CspViolationReportReceived;
use Illuminate\Support\Facades\Event;
Event::listen(CspViolationReportReceived::class, function (CspViolationReportReceived $event) {
if ($event->violationReport->data->blocked_uri === 'https://example.com') {
$event->shouldReport = false;
}
});
namespace App\Listeners;
use Bretto36\CspReporting\Event\CspViolationReportReceived;
class CspViolationReportReceivedListener
{
/**
* Handle the event.
*/
public function handle(CspViolationReportReceived $event): void
{
// Apply logic here
$event->shouldReport = false;
}
}