PHPackages                             deployecommerce/magento2-csp-writer - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. deployecommerce/magento2-csp-writer

ActiveLibrary[HTTP &amp; Networking](/categories/http)

deployecommerce/magento2-csp-writer
===================================

A PHP library to write a Magento 2/Adobe Commerce whitelist.xml file from a structured array.

0.0.8(1y ago)1171OSL-3.0PHP

Since Apr 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/DeployEcommerce/magento2-csp-writer)[ Packagist](https://packagist.org/packages/deployecommerce/magento2-csp-writer)[ RSS](/packages/deployecommerce-magento2-csp-writer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (8)Used By (0)

Magento 2 CSP Writer
====================

[](#magento-2-csp-writer)

This library is a simple CSP writer for Magento 2.

It can be used to write a `csp_whitelist.xml` file given a structured array.

The policies array should be in the format:

```
$policies = [
    'default-src' => [
        [
            'type' => 'host',
            'name' => 'example.com',
            'value' => 'https://example.com',
            'directive' => 'default-src',
        ],
        [
            'type' => 'host',
            'name' => '*.example.com',
            'value' => '*.example.com',
            'directive' => 'default-src',
        ],
    ],
];

```

Create a writer instance and call the `generate` method with the structured array:

```
$writer = new DeployEcommerce\Csp\Writer\Magento2CspWriter();
$xml = $writer->generate($policies);
```

You'll then be returned the following XML to write to your `csp_whitelist.xml` file:

```

                https://example.com
                *.example.com

```

This can be used in conjunction with the [DeployEcommerce/magento2-csp-parser](https://github.com/DeployEcommerce/magento2-csp-parser)package to parse an existing `csp_whitelist.xml` file and return you a structured array.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance49

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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.

###  Release Activity

Cadence

Every ~0 days

Total

7

Last Release

401d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/254889?v=4)[Scott](/maintainers/ssx)[@ssx](https://github.com/ssx)

![](https://avatars.githubusercontent.com/u/2587545?v=4)[Nathan Chick](/maintainers/nathanchick)[@nathanchick](https://github.com/nathanchick)

---

Top Contributors

[![ssx](https://avatars.githubusercontent.com/u/254889?v=4)](https://github.com/ssx "ssx (8 commits)")

---

Tags

httpparsersecuritymagentoheaderscspcontent-security-policymagento2commerceadobepci

### Embed Badge

![Health badge](/badges/deployecommerce-magento2-csp-writer/health.svg)

```
[![Health](https://phpackages.com/badges/deployecommerce-magento2-csp-writer/health.svg)](https://phpackages.com/packages/deployecommerce-magento2-csp-writer)
```

###  Alternatives

[paragonie/csp-builder

Easily add and update Content-Security-Policy headers for your project

5412.8M18](/packages/paragonie-csp-builder)[spatie/laravel-csp

Add CSP headers to the responses of a Laravel app

8519.6M19](/packages/spatie-laravel-csp)[middlewares/csp

Middleware to add the Content-Security-Policy header to the response

1720.6k](/packages/middlewares-csp)[mimmi20/browser-detector

Library to detect Browsers and Devices

48153.5k3](/packages/mimmi20-browser-detector)[bakame/http-structured-fields

A PHP library that parses, validates and serializes HTTP structured fields according to RFC9561 and RFC8941

442.6k4](/packages/bakame-http-structured-fields)[vdb/uri

A set of URI classes and a URI parser, based on RFC 3986

11225.6k2](/packages/vdb-uri)

PHPackages © 2026

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