PHPackages                             kenjis/csp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. kenjis/csp

ActiveLibrary[Security](/categories/security)

kenjis/csp
==========

Implementation of Content Security Policy (CSP) nonce-source

62.7k1[2 issues](https://github.com/kenjis/php-csp-nonce-source/issues)[2 PRs](https://github.com/kenjis/php-csp-nonce-source/pulls)PHP

Since Feb 2Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kenjis/php-csp-nonce-source)[ Packagist](https://packagist.org/packages/kenjis/csp)[ RSS](/packages/kenjis-csp/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (3)Used By (0)

CSP nonce-source for PHP
========================

[](#csp-nonce-source-for-php)

[![Build Status](https://camo.githubusercontent.com/71f7041113e0abdb6db3894ff9e4b4fe58e599b44b5e61b41ae26bd544a1b3c4/68747470733a2f2f7472617669732d63692e6f72672f6b656e6a69732f7068702d6373702d6e6f6e63652d736f757263652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kenjis/php-csp-nonce-source)[![Code Coverage](https://camo.githubusercontent.com/d802c5f3b3401e1f9d063822723c8b36e78748e4f926c67a911f32e65ad961da/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b656e6a69732f7068702d6373702d6e6f6e63652d736f757263652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kenjis/php-csp-nonce-source/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1d8d12ef325c66767466182201197a2ce290001831cca73ccf77f8e31657ad51/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b656e6a69732f7068702d6373702d6e6f6e63652d736f757263652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kenjis/php-csp-nonce-source/?branch=master)

CSP (Content Security Policy) nonce-source library for PHP.

What is CSP nonce-source?
-------------------------

[](#what-is-csp-nonce-source)

It is one of CSP 2 features to prevent XSS.

If you don't know, please see [CSP for the web we have | Mozilla Security Blog](https://blog.mozilla.org/security/2014/10/04/csp-for-the-web-we-have/).

Requirement
-----------

[](#requirement)

- PHP 5.4 or lator

Installation
------------

[](#installation)

```
$ git clone https://github.com/kenjis/php-csp-nonce-source.git
$ cd php-csp-nonce-source
$ composer install

```

Usage
-----

[](#usage)

All you have to call is only `Csp::sendHeader()` and `Csp::getNonce()`.

`Csp::sendHeader()` sends CSP header.

`Csp::getNonce()` returns nonce value.

```

Sample of CSP nonce-source
