PHPackages                             thefredfox/cakephp-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. thefredfox/cakephp-csp

ActiveCakephp-plugin[Security](/categories/security)

thefredfox/cakephp-csp
======================

Makes CakePHP 3 CSP supportable by removing inline javascript and inline styles.

42.8k1PHP

Since Apr 15Pushed 10y ago3 watchersCompare

[ Source](https://github.com/TheFRedFox/cakephp-csp)[ Packagist](https://packagist.org/packages/thefredfox/cakephp-csp)[ RSS](/packages/thefredfox-cakephp-csp/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Csp plugin for CakePHP
======================

[](#csp-plugin-for-cakephp)

Description
-----------

[](#description)

This plugin does some slight changes in the FormHelper and HtmlHelper, so there won't be any inline script resp. style anymore, so the developer can easily add CSP headers.

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require thefredfox/cakephp-csp

```

Configuration
-------------

[](#configuration)

To load this Plugin inside CakePHP:

```
// in bootstrap.php file
Plugin::load('Csp');
```

In your layout or your pages, you have to load the css and js files of the csp plugin:

```
// in your layout/page file
$this->Html->css('Csp.csp');
$this->Html->script('Csp.csp'); //this script has to be loaded at the bottom
```

If you don't use any other FormHelper or HtmlHelper yet, you can easily use the Helpers of this plugin:

```
// in your AppView
public function initialize()
{
  $this->loadHelper('Csp.Html');
  $this->loadHelper('Csp.Form');
}
```

### Extending third party helpers

[](#extending-third-party-helpers)

If you are using another FormHelper or HtmlHelper (e.g. the BootstrapUI helpers), you may use the Traits provided by this plugin in an own extending Helper class:

```
// in src/View/Helper/FormHelper

class FormHelper extends \BootstrapUI\View\Helper\FormHelper {

  use \Csp\View\Helper\FormHelperTrait;

}
```

### Extending your own helpers

[](#extending-your-own-helpers)

If you already extends one of the helpers, you can try to use the Trait like above, but you may want to extend your helper again to not override something.

```
// in src/View/Helper/CspFormHelper (or the like)

class CspFormHelper extends FormHelper {

  use \Csp\View\Helper\FormHelperTrait;

}
```

I tried it with my own Helper classes, which extends the BootstrapUI classes. In the HtmlHelper class I already override the link function which also is overridden by the Csp-plugin's HtmlHelper, so I create another CspHtmlHelper class which extends my other HtmlHelper and uses the HtmlHelperTrait by the csp plugin. It works. ;)

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5676670?v=4)[Frederik Bauer](/maintainers/TheFRedFox)[@TheFRedFox](https://github.com/TheFRedFox)

---

Top Contributors

[![TheFRedFox](https://avatars.githubusercontent.com/u/5676670?v=4)](https://github.com/TheFRedFox "TheFRedFox (14 commits)")

---

Tags

cakephpcakephp3content-security-policycspplugin

### Embed Badge

![Health badge](/badges/thefredfox-cakephp-csp/health.svg)

```
[![Health](https://phpackages.com/badges/thefredfox-cakephp-csp/health.svg)](https://phpackages.com/packages/thefredfox-cakephp-csp)
```

###  Alternatives

[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k18.7M141](/packages/mews-purifier)[paragonie/ecc

PHP Elliptic Curve Cryptography library

24820.0k36](/packages/paragonie-ecc)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
