PHP code example of synchro / laravel-violations

1. Go to this page and download the library: Download synchro/laravel-violations 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/ */

    

synchro / laravel-violations example snippets


use \Synchro\Violation\Http\Middleware\AddReportingHeaders;
//...
->withMiddleware(function (Middleware $middleware) {
        $middleware->append(AddCspHeaders::class); //From Spatie's CSP package
        $middleware->append(AddReportingHeaders::class);
    })

return response($content)
    ->header('Content-Security-Policy', 'default-src \'self\'; report-to '.Synchro\Violation\Violation::cspReportTo());

'report-uri' => \Synchro\Violation\Violation::cspReportUri(),
'report-to' => \Synchro\Violation\Violation::cspReportTo(),

Route::violations();
bash
php artisan vendor:publish --tag="violations-config"
bash
php artisan vendor:publish --tag="violations-migrations"
php artisan migrate