Download the PHP package audunru/reporting-api without Composer

On this page you can find all versions of the php package audunru/reporting-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package reporting-api

Receive W3C Reporting API and CSP violation reports in Laravel

Build Status Coverage Status

Browsers send batched reports — CSP violations, deprecations, network errors, crashes, and more — to a configured endpoint. This package registers that endpoint, decodes the payload, and dispatches Laravel events for each report type.

Requirements

Installation

The service provider is auto-discovered. The package registers a POST /reports route automatically.

Sending reports from a browser

Legacy CSP reports (application/csp-report)

Set the report-uri directive in your Content-Security-Policy header:

With spatie/laravel-csp:

Modern Reporting API (application/reports+json)

Use Reporting-Endpoints and report-to to send batched reports in the modern format:

The modern format supports additional report types beyond CSP violations (deprecations, network errors, crashes, etc.).

With spatie/laravel-csp, add Directive::REPORT_TO in your Policy class:

Also apply the reporting-endpoints middleware (see Middleware) so the Reporting-Endpoints header is sent to browsers alongside the CSP header.

For legacy browser fallback (Firefox and Safari do not support report-to), also set report_uri in config/csp.php. Modern browsers ignore report-uri when report-to is present, so each browser uses the right format automatically:

Getting started

When a report arrives the package dispatches a Laravel event based on the report type. The package ships two ready-made listeners — LogCspViolation and LogReport — that you can register directly in AppServiceProvider::boot():

LogCspViolation logs CSP violations as warning. LogReport logs every other report type as info, with the full raw report in the log context. Neither is registered automatically.

Both log to the stack channel by default. Override protected string $channel to redirect to a different channel:

Filtering noise with shouldExclude()

Browser extensions routinely trigger CSP reports. Override shouldExclude() in a subclass to filter them out:

LogReport supports the same pattern via its Report base type:

Register your subclasses the same way:

Middleware

The package registers a reporting-endpoints middleware alias that adds the Reporting-Endpoints header to responses. Browsers use this header to discover where to POST their reports.

Apply it to specific routes or route groups:

To add it globally to all web routes (Laravel 11+, bootstrap/app.php):

The header value uses the path from your config:

Configuration

Publish the config file to customise the endpoint path and throttle limit:

Key Env var Default Description
path REPORTING_API_PATH /reports URL path of the report endpoint
throttle REPORTING_API_THROTTLE 60,1 Throttle value — named limiter or attempts,minutes

Reference

Dispatched events

Event class Trigger
CspViolationReceived csp-violation type (modern) or application/csp-report (legacy)
DeprecationReportReceived deprecation type
InterventionReportReceived intervention type
CrashReportReceived crash type
NetworkErrorReceived network-error type
CoepReportReceived coep type
CoopReportReceived coop type
DocumentPolicyViolationReceived document-policy-violation type
GenericReportReceived Any unrecognized type

Event interface

All event classes implement audunru\ReportingApi\Contracts\ReportEvent and expose:

Method Returns
getReport() Typed report DTO (e.g. CspViolationReport)
getRawReport() Raw report array as received from the browser

Report DTOs

getReport() returns a typed DTO that extends audunru\ReportingApi\DTOs\Report, with properties common to all report types:

Property Type Description
type string W3C report type (e.g. 'csp-violation')
url ?string URL of the page that generated the report
age ?int Milliseconds between report generation and sending
userAgent ?string Browser user agent string

Each specific report DTO also has a typed body property whose class matches the report type:

Event getReport() returns body type
CspViolationReceived CspViolationReport CspViolationReportBody
DeprecationReportReceived DeprecationReport DeprecationReportBody
InterventionReportReceived InterventionReport InterventionReportBody
CrashReportReceived CrashReport CrashReportBody
NetworkErrorReceived NetworkErrorReport NetworkErrorReportBody
CoepReportReceived CoepViolationReport CoepViolationReportBody
CoopReportReceived CoopViolationReport CoopViolationReportBody
DocumentPolicyViolationReceived DocumentPolicyViolationReport DocumentPolicyViolationReportBody
GenericReportReceived GenericReport ?array

Body classes are plain PHP objects with nullable readonly properties matching the W3C specification for that report type. For example, CspViolationReportBody exposes blockedURL, effectiveDirective, disposition, documentURL, originalPolicy, and so on.


All versions of reporting-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
laravel/framework Version ^13.0
spatie/laravel-package-tools Version ^1.9
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package audunru/reporting-api contains the following files

Loading the files please wait ...