kingsoft / csp-builder
Content Security Policy builder for PHP
1.2.0
2024-12-18 09:25 UTC
Requires (Dev)
- phpunit/phpunit: ^12.0@dev
README
Generate a CSP header
Installation
This project using composer.
composer require kingsoft/csp-builder
Usage
<?php use CSP\CspBuilder; $csp = (new CspBuilder()) ->addCspPolicy('script-src', CspBuilder::SELF) ->addCspPolicy('script-src', CspBuilder::NONCE) ->addCspPolicyNonce('script-src') ->setCspHeader(); define('NONCE', $csp-> getNonce()); <script nonce="<?= NONCE ?>"> </script>