Download the PHP package wpify/scoper without Composer
On this page you can find all versions of the php package wpify/scoper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package scoper
Short Description Composer plugin that scopes WordPress and WooCommerce dependencies for usage in WordPress plugins and themes.
License GPL-2.0-or-later
Informations about the package scoper
WPify Scoper - A scoper for WordPress plugins and themes
Using Composer in your WordPress plugin or theme can benefit from that. But it also comes with a danger of conflicts with dependencies of other plugins or themes. Luckily, a great tool called PHP Scoper adds all your needed dependencies to your namespace to prevent conflicts. Unfortunately, the configuration is non-trivial, and for that reason, we created the Composer plugin to make scoping easy in WordPress projects.
The main issue with PHP Scoper is that it also scopes global functions, constants and classes. Usually, that is what you want, but that also means that WordPress functions, classes and constants will be scoped. This Composer plugin solves that. It has an up-to-date database of all WordPress and WooCommerce symbols that we want to keep unscoped.
Requirements
- wpify/scoper:3.1
- PHP 7.4 || 8.0
- wpify/scoper:3.2
- PHP >= 8.1
Usage
- This composer plugin is meant to be installed globally, but you can also require it as a dev dependency.
- The configuration requires creating
composer-deps.json
file, that has exactly same structure likecomposer.json
file, but serves only for scoped dependencies. Dependencies that you don't want to scope comes tocomposer.json
. - Add
extra.wpify-scoper.prefix
to youcomposer.json
, where you can specify the namespace, where your dependencies will be in. All other config options (folder
,globals
,composerjson
,composerlock
,autorun
) are optional. - The easiest way how to use the scoper on development environment is to install WPify Scoper as a dev dependency.
After each
composer install
orcomposer update
, all the dependencies specified incomposer-deps.json
will be scoped for you. - Add a
config.platform
option in your composer.json and composer-deps.json. This settings will make sure that the dependencies will be installed with the correct PHP version.
Example of composer.json
with its default values
-
Option
autorun
defaults totrue
so that scoping is run automatically upon composerupdate
orinstall
command. That is not what you want in all cases, so you can set itfalse
if you need. To start prefixing manually, you need to add for example the line"wpify-scoper": "wpify-scoper"
to the "scripts" section of your composer.json. You then run the script with the commandcomposer wpify-scoper install
orcomposer wpify-scoper update
. -
Scoped dependencies will be in
deps
folder of your project. You must include the scoped autoload alongside with the composer autoloader. - After that, you can use your dependencies with the namespace.
Example PHP file:
Deployment
Deployment with Gitlab CI
To use WPify Scoper with Gitlab CI, you can add the following job to your .gitlab-ci.yml
file:
Deployment with Github Actions
To use WPify Scoper with Github Actions, you can add the following action:
Advanced configuration
PHP Scoper has plenty
of configuration options. You
can modify this configuration array by creating scoper.custom.php
file in root of your project. The file should
contain customize_php_scoper_config
function, where the first parameter is the preconfigured configuration array. Expected output is
valid PHP Scoper configuration array.
Example scoper.custom.php
file
All versions of scoper with dependencies
composer-plugin-api Version ^2.3
composer/composer Version ^2.6
wpify/php-scoper Version ^0.18