PHPackages                             shinepress/globals - 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. shinepress/globals

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shinepress/globals
==================

Allow ShinePress modules to register global functions and variables.

1.0.0(12mo ago)013MITPHPPHP &gt;=8.1CI passing

Since May 19Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/shinepress/globals)[ Packagist](https://packagist.org/packages/shinepress/globals)[ RSS](/packages/shinepress-globals/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (4)Used By (0)

shinepress/globals
==================

[](#shinepressglobals)

[![License](https://camo.githubusercontent.com/c08684ee23097e774e004535cc546844d0976f0945686bb7361a3be536fa7b76/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7368696e6570726573732f676c6f62616c73)](https://github.com/shinepress/globals/blob/main/LICENSE)[![Latest Version](https://camo.githubusercontent.com/8494553d5b1a837d01727efaee0f09f5c85599d1e3f5cd9b3490b10318e3e843/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7368696e6570726573732f676c6f62616c733f6c6162656c3d6c6174657374)](https://packagist.org/packages/shinepress/globals/)[![PHP Version](https://camo.githubusercontent.com/bf4ce9a7133691a0aeba647b8245d8f35aec4a7975710d4541f0ed3c3348a71b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7368696e6570726573732f676c6f62616c732f7068703f6c6162656c3d706870)](https://www.php.net/releases/index.php)[![Main Status](https://camo.githubusercontent.com/9b190d904cb27c3b4ddb12dccb18dcfa8717194d4b8ec447002719ab9aa77a52/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7368696e6570726573732f676c6f62616c732f7665726966792e796d6c3f6272616e63683d6d61696e266c6162656c3d6d61696e)](https://github.com/shinepress/globals/actions/workflows/verify.yml?query=branch%3Amain)[![Release Status](https://camo.githubusercontent.com/09a23abfb0e082c49bdb9d12395177989ccb6dfe6830394953ebea17593aa0f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7368696e6570726573732f676c6f62616c732f7665726966792e796d6c3f6272616e63683d72656c65617365266c6162656c3d72656c65617365)](https://github.com/shinepress/globals/actions/workflows/verify.yml?query=branch%3Arelease)[![Develop Status](https://camo.githubusercontent.com/4e38461048f7e26f8e2771a30fc36ecdfaff4b816d1998ca782789146f23bea6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7368696e6570726573732f676c6f62616c732f7665726966792e796d6c3f6272616e63683d646576656c6f70266c6162656c3d646576656c6f70)](https://github.com/shinepress/globals/actions/workflows/verify.yml?query=branch%3Adevelop)

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

[](#description)

Add-on for [shinepress/framework](https://packagist.org/packages/shinepress/framework/) to allow registering of global variables, functions, and constants for use outside of modules.

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

[](#installation)

The recommendend installation method is with composer:

```
$ composer require shinepress/globals
```

Usage
-----

[](#usage)

Add the 'RegisterGlobal' attribute to any module class/property/constant/method to register it into the global namespace.

### Module Instance

[](#module-instance)

```
use ShinePress\Framework\Module;
use ShinePress\Globals\RegisterGlobal;

#[RegisterGlobal('module')] // registers as $module
#[RegisterGlobal] // registers as $ExampleModule
class ExampleModule extends Module {

	public function hello(): string {
		return 'world';
	}
}

ExampleModule::register();
```

```
global $module;
print $module->hello();
// prints: 'world'
```

```
global $ExampleModule;
print $ExampleModule->hell();
// prints: 'world'
```

### Module Property

[](#module-property)

Assigns a reference to the indicated class property to the global variable regardless of visibility.

```
use ShinePress\Framework\Module;
use ShinePress\Globals\RegisterGlobal;

class ExampleModule extends Module {

	#[RegisterGlobal('testProperty')]
	public string $myProperty = 'foo';
}

ExampleModule::register();
```

```
global $testProperty;
print $testProperty;
// prints: 'foo';

$testProperty = 'bar';
print ExampleModule::instance()->myProperty;
// prints: 'bar'
```

### Module Constant

[](#module-constant)

Defines a global constant with the value of the class constant regardless of visibility.

```
use ShinePress\Framework\Module;
use ShinePress\Globals\RegisterGlobal;

class ExampleModule extends Module {

	#[RegisterGlobal('TEST_CONSTANT')]
	public const MY_CONSTANT = 'foobar';
}

ExampleModule::register();
```

```
print TEST_CONSTANT;
// prints: 'foobar'
```

### Module Method

[](#module-method)

Creates a closure reference to the indicated method and assigns it to a function in the global scope.

Note: the relies on eval, with all the associated downsides.

```
use ShinePress\Framework\Module;
use ShinePress\Globals\RegisterGlobal;

class ExampleModule extends Module {

	#[RegisterGlobal('toLowercase')]
	public function lowercase(string $input): string {
		return strtolower($input);
	}

	#[RegisterGlobal('toUppercase')]
	public function uppercase(string $input): string {
		return strtoupper($input);
	}
}

ExampleModule::register();
```

```
print toLowercase('HELLOWORLD');
// prints: 'helloworld'

print toUppercase('helloworld');
// prints: 'HELLOWORLD'
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance50

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.7% 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

364d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8301342?v=4)[Shine United](/maintainers/shineunited)[@shineunited](https://github.com/shineunited)

---

Top Contributors

[![rmlasseter](https://avatars.githubusercontent.com/u/5660821?v=4)](https://github.com/rmlasseter "rmlasseter (18 commits)")[![shineadmin](https://avatars.githubusercontent.com/u/3662582?v=4)](https://github.com/shineadmin "shineadmin (1 commits)")

---

Tags

wordpressglobals

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/shinepress-globals/health.svg)

```
[![Health](https://phpackages.com/badges/shinepress-globals/health.svg)](https://phpackages.com/packages/shinepress-globals)
```

###  Alternatives

[tgmpa/tgm-plugin-activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins).

1.8k222.5k13](/packages/tgmpa-tgm-plugin-activation)[aristath/kirki

Extending the WordPress customizer

1.3k73.0k4](/packages/aristath-kirki)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[php-stubs/wordpress-globals

Global variables and global constants from WordPress core.

13799.0k17](/packages/php-stubs-wordpress-globals)[justintadlock/hybrid-carbon

God-like post featured image script.

202.5k](/packages/justintadlock-hybrid-carbon)

PHPackages © 2026

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