PHPackages                             automattic/jetpack-constants - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. automattic/jetpack-constants

ActiveJetpack-library[Utility &amp; Helpers](/categories/utility)

automattic/jetpack-constants
============================

A wrapper for defining constants in a more testable way.

v3.0.8(1y ago)54.3M—4.1%120GPL-2.0-or-laterPHPPHP &gt;=7.2CI failing

Since Jun 17Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Automattic/jetpack-constants)[ Packagist](https://packagist.org/packages/automattic/jetpack-constants)[ RSS](/packages/automattic-jetpack-constants/feed)WikiDiscussions trunk Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (63)Used By (20)

Jetpack Constants
=================

[](#jetpack-constants)

A simple constant manager for Jetpack.

Testing constants is hard. Once you define a constant in PHP, it's defined. Constants Manager is an abstraction layer so that unit tests can set constants for tests.

### Usage

[](#usage)

Retrieve the value of a constant `CONSTANT_NAME` (returns `null` if it's not defined):

```
use Automattic\Jetpack\Constants;

$constant_value = Constants::get_constant( 'CONSTANT_NAME' );
```

Set the value of a constant `CONSTANT_NAME` to a particular value:

```
use Automattic\Jetpack\Constants;

$value = 'some value';
Constants::set_constant( 'CONSTANT_NAME', $value );
```

Check whether a constant `CONSTANT_NAME` is defined:

```
use Automattic\Jetpack\Constants;

$defined = Constants::is_defined( 'CONSTANT_NAME' );
```

Check whether a constant `CONSTANT_NAME` is truthy:

```
use Automattic\Jetpack\Constants;

$is_truthy = Constants::is_true( 'CONSTANT_NAME' );
```

Delete the `CONSTANT_NAME` constant:

```
use Automattic\Jetpack\Constants;

Constants::clear_single_constant( 'CONSTANT_NAME' );
```

Delete all known constants:

```
use Automattic\Jetpack\Constants;

Constants::clear_constants();
```

Using this package in your WordPress plugin
-------------------------------------------

[](#using-this-package-in-your-wordpress-plugin)

If you plan on using this package in your WordPress plugin, we would recommend that you use [Jetpack Autoloader](https://packagist.org/packages/automattic/jetpack-autoloader) as your autoloader. This will allow for maximum interoperability with other plugins that use this package as well.

Security
--------

[](#security)

Need to report a security vulnerability? Go to  or directly to our security bug bounty site .

License
-------

[](#license)

jetpack-constants is licensed under [GNU General Public License v2 (or later)](./LICENSE.txt)

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance71

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community35

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~44 days

Recently: every ~11 days

Total

49

Last Release

385d ago

Major Versions

v1.6.23 → v2.0.02023-11-20

v2.0.5 → v3.0.02024-11-14

PHP version history (2 changes)v2.0.0PHP &gt;=7.0

v3.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c5869ecbb8e0eac7e8b8e0f3cf7bdd8d5fcdc4abc10a72281872c53f8639d44?d=identicon)[automattic](/maintainers/automattic)

---

Top Contributors

[![anomiex](https://avatars.githubusercontent.com/u/1030580?v=4)](https://github.com/anomiex "anomiex (89 commits)")[![tbradsha](https://avatars.githubusercontent.com/u/32492176?v=4)](https://github.com/tbradsha "tbradsha (21 commits)")[![jeherve](https://avatars.githubusercontent.com/u/426388?v=4)](https://github.com/jeherve "jeherve (17 commits)")[![kraftbj](https://avatars.githubusercontent.com/u/88897?v=4)](https://github.com/kraftbj "kraftbj (15 commits)")[![samiff](https://avatars.githubusercontent.com/u/15803018?v=4)](https://github.com/samiff "samiff (10 commits)")[![zinigor](https://avatars.githubusercontent.com/u/374293?v=4)](https://github.com/zinigor "zinigor (8 commits)")[![coder-karen](https://avatars.githubusercontent.com/u/16754605?v=4)](https://github.com/coder-karen "coder-karen (5 commits)")[![gmjuhasz](https://avatars.githubusercontent.com/u/36671565?v=4)](https://github.com/gmjuhasz "gmjuhasz (4 commits)")[![tyxla](https://avatars.githubusercontent.com/u/8436925?v=4)](https://github.com/tyxla "tyxla (4 commits)")[![dereksmart](https://avatars.githubusercontent.com/u/7129409?v=4)](https://github.com/dereksmart "dereksmart (3 commits)")[![ice9js](https://avatars.githubusercontent.com/u/8056203?v=4)](https://github.com/ice9js "ice9js (2 commits)")[![gravityrail](https://avatars.githubusercontent.com/u/51896?v=4)](https://github.com/gravityrail "gravityrail (2 commits)")[![kbrown9](https://avatars.githubusercontent.com/u/50059399?v=4)](https://github.com/kbrown9 "kbrown9 (2 commits)")[![manzoorwanijk](https://avatars.githubusercontent.com/u/18226415?v=4)](https://github.com/manzoorwanijk "manzoorwanijk (2 commits)")[![nunyvega](https://avatars.githubusercontent.com/u/16329583?v=4)](https://github.com/nunyvega "nunyvega (2 commits)")[![sdixon194](https://avatars.githubusercontent.com/u/33553323?v=4)](https://github.com/sdixon194 "sdixon194 (2 commits)")[![sergeymitr](https://avatars.githubusercontent.com/u/1341249?v=4)](https://github.com/sergeymitr "sergeymitr (2 commits)")[![dhasilva](https://avatars.githubusercontent.com/u/8486249?v=4)](https://github.com/dhasilva "dhasilva (1 commits)")[![allilevine](https://avatars.githubusercontent.com/u/1689238?v=4)](https://github.com/allilevine "allilevine (1 commits)")[![chihsuan](https://avatars.githubusercontent.com/u/4344253?v=4)](https://github.com/chihsuan "chihsuan (1 commits)")

---

Tags

jetpack

### Embed Badge

![Health badge](/badges/automattic-jetpack-constants/health.svg)

```
[![Health](https://phpackages.com/badges/automattic-jetpack-constants/health.svg)](https://phpackages.com/packages/automattic-jetpack-constants)
```

###  Alternatives

[ps/fluent-traversable

Support for operating on collections and arrays by functional way. Inspired by guava's FluentIterable, java8 Stream framework and scala stuff

2929.4k1](/packages/ps-fluent-traversable)

PHPackages © 2026

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