PHPackages                             tombroucke/wp-plugin-php-scoper-example - 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. tombroucke/wp-plugin-php-scoper-example

ActiveWordpress-plugin

tombroucke/wp-plugin-php-scoper-example
=======================================

1.0.0(5mo ago)22PHP

Since Dec 2Pushed 3mo agoCompare

[ Source](https://github.com/tombroucke/wp-plugin-php-scoper-example)[ Packagist](https://packagist.org/packages/tombroucke/wp-plugin-php-scoper-example)[ RSS](/packages/tombroucke-wp-plugin-php-scoper-example/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

WP Plugin PHP scoper example
============================

[](#wp-plugin-php-scoper-example)

This example plugin shows how you can introduce [PHP-Scoper](https://github.com/humbug/php-scoper) to your WordPress plugin.

In this project, PHP-scoper will prefix all dependencies. We build a `vendor_prefixed` directory that contains all the prefixed dependencies. devDependencies will be installed to the `vendor` directory, so we can run tests (`composer test`). As the scoped dependencies are not in the `composer.json` `require` list, this plugin can be installed alongside other version of dependencies. E.g. if your root `composer.json` requires `psr/log ^1` or `psr/log ^3`, you will still be able to install this plugin.

See it in action
----------------

[](#see-it-in-action)

To install this example plugin you can run

```
composer require tombroucke/wp-plugin-php-scoper-example

```

Alternatively, you can download the zipfile and place it in your `(app|wp-content)/plugins`.

Building vendor\_prefixed
-------------------------

[](#building-vendor_prefixed)

### Prerequisites

[](#prerequisites)

- **jq** (`brew install jq`)
- **php-scoper** (`composer global require humbug/php-scoper`)

### Run the build script

[](#run-the-build-script)

Run `composer build` (or `./scoper.sh`) to build the `vendor_prefixed` directory. This will:

- Fetch dependencies that need prefixes from `composer.json`
- Install these dependencies (`composer require {dependency}`)
- Run `composer update`
- Add prefixes
- Remove all devDependencies
- Move the prefixed vendor dir from `build/vendor` to `vendor_prefixed`
- Set custom suffix (`PhpScoperExampleVendorSuffix`) for `ComposerAutoloaderInit`
- Remove the scoped dependencies from `composer.json`

Adding dependencies
-------------------

[](#adding-dependencies)

To add dependencies, you can add them in `extra.require-scoped` in `composer.json`. After adding the dependency, you need to rebuild the `vendor_prefixed` directory.

Integrating in an existing plugin
---------------------------------

[](#integrating-in-an-existing-plugin)

1. install **jq** (`brew install jq`) and **php-scoper** (`composer global require humbug/php-scoper`)
2. Copy `scoper.inc.php`, replace `'prefix' => 'PhpScoperExampleVendor'` with your prefix and `'exclude-namespaces' => ['Otomaties\\PhpScoperExample']` at the bottom of the file with the namespace of your plugin.
3. Copy `scoper.sh`, replace `PhpScoperExampleVendorSuffix` with a custom suffix
4. Copy the build scripts from `composer.json`
5. Add your dependencies in `extra.require-scoped` in `composer.json`
6. Run `composer build`
7. Find &amp; replace the namespaces in your plugin. (`use Illuminate\Support\Collection` &gt; `use PhpScoperExampleVendor\Illuminate\Support\Collection`)
8. Include `vendor_prefixed` in your repository (should NOT be .gitignored)

FAQ
---

[](#faq)

Why not use the dependencies from `require` in `composer.json`?

> I want this plugin to be installable with composer. If the project requires `psr/log ^2`, and my `composer.json` file requires `psr/log ^3`, composer would not be able to install the plugin.

Why do I need a custom suffix for `ComposerAutoloaderInit`?

> The classname `ComposerAutoloaderInit{calculated_hash}` in `vendor_prefixed` would otherwise collide with the classname in `vendor`

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance75

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

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

167d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4178291ccf36e3530aa8a8845124c3af1b24c064739ad98ded5b9679a4316033?d=identicon)[tombroucke](/maintainers/tombroucke)

---

Top Contributors

[![tombroucke](https://avatars.githubusercontent.com/u/24292260?v=4)](https://github.com/tombroucke "tombroucke (7 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/tombroucke-wp-plugin-php-scoper-example/health.svg)

```
[![Health](https://phpackages.com/badges/tombroucke-wp-plugin-php-scoper-example/health.svg)](https://phpackages.com/packages/tombroucke-wp-plugin-php-scoper-example)
```

PHPackages © 2026

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