Download the PHP package tombroucke/wp-plugin-php-scoper-example without Composer

On this page you can find all versions of the php package tombroucke/wp-plugin-php-scoper-example. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-plugin-php-scoper-example

WP Plugin PHP scoper example

This example plugin shows how you can introduce 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

To install this example plugin you can run

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

Building vendor_prefixed

Prerequisites

Run the build script

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

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

  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 & replace the namespaces in your plugin. (use Illuminate\Support\Collection > use PhpScoperExampleVendor\Illuminate\Support\Collection)
  8. Include vendor_prefixed in your repository (should NOT be .gitignored)

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


All versions of wp-plugin-php-scoper-example with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tombroucke/wp-plugin-php-scoper-example contains the following files

Loading the files please wait ...