PHPackages                             deployecommerce/magento2-csp-parser - 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-parser

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

deployecommerce/magento2-csp-parser
===================================

A library which will parse a Magento 2 CSP whitelist file into a structured array.

0.0.1(1y ago)061OSL-3.0PHP

Since Apr 2Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

Magento 2 CSP Parser
====================

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

This library is a simple CSP parser for Magento 2.

It can be used to parse an existing `csp_whitelist.xml` file and return you a structured array.

Create a parser instance and call the `parse` method with the contents of your file:

```
$xml = file_get_contents('csp_whitelist.xml');

$parser = new \DeployEcommerce\Csp\Parser\Magento2CspParser();
$policies = $parser->parse($xml);
```

An array will be returned containing the parsed elements:

```
  "style-src" => array:6 [▼
    0 => array:4 [▼
      "type" => "host"
      "name" => "hotjar"
      "value" => "*.hotjar.com"
      "directive" => "style-src"
    ]
    1 => array:4 [▼
      "type" => "host"
      "name" => "gmaps"
      "value" => "maps.googleapis.com"
      "directive" => "style-src"
    ]
    2 => array:4 [▼
      "type" => "host"
      "name" => "cookiebot"
      "value" => "*.cookiebot.com"
      "directive" => "style-src"
    ]
  ]
  "font-src" => array:5 [▶]
  "img-src" => array:15 [▶]
  "frame-src" => array:7 [▶]
  "media-src" => array:7 [▶]
  "connect-src" => array:17 [▶]
  "form-action" => array:2 [▶]
]

```

This can be used in conjunction with the [DeployEcommerce/magento2-csp-writer](https://github.com/DeployEcommerce/magento2-csp-writer) package to generate a CSP file as well.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance46

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity27

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

Unknown

Total

1

Last Release

411d 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 (1 commits)")

---

Tags

httpparsersecuritymagentoheaderscspcontent-security-policymagento2commerceadobepci

### Embed Badge

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

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

###  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

8569.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)
