PHP code example of fyre / csp
1. Go to this page and download the library: Download fyre/csp 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/ */
fyre / csp example snippets
use Fyre\Security\ContentSecurityPolicy;
$csp = new ContentSecurityPolicy($config);
$container->use(Config::class)->set('Csp', $options);
$container->singleton(ContentSecurityPolicy::class);
$csp = $container->use(ContentSecurityPolicy::class);
$newResponse = $csp->addHeaders($response);
$csp->clear();
$csp->createPolicy($key, $directives);
$policy = $csp->getPolicy($key);
$policies = $csp->getPolicies();
$reportTo = $csp->getReportTo();
$hasPolicy = $csp->hasPolicy($key);
$csp->setPolicy($key, $policy);
$csp->setReportTo($reportTo);
$newPolicy = $policy->addDirective($directive, $value);
$options = $policy->getDirective($directive);
$header = $policy->getHeader();
$hasDirective = $policy->hasDirective($directive);
$newPolicy = $policy->removeDirective($directive);
use Fyre\Security\Middleware\CspMiddleware;
$middleware = new CspMiddleware($csp);
$middleware = $container->build(CspMiddleware::class);
$response = $middleware->handle($request, $next);