Download the PHP package devuri/wp-adapter without Composer

On this page you can find all versions of the php package devuri/wp-adapter. 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-adapter

WP Adapter

WordPress adapter contracts and in-memory testing doubles for clean, testable plugin development.

The problem this solves

WordPress plugins commonly call get_option(), add_action(), and wp_remote_post() directly inside business logic. That makes the logic impossible to unit test without bootstrapping WordPress, and it makes the plugin hard to reason about.

WP Adapter gives us a thin set of contracts for common WordPress APIs and matching in-memory implementations for tests. Our plugin code depends only on the contracts. WordPress stays at the edge.

In production we pass the WordPress adapters. In tests we pass the in-memory fakes. No mocks. No bootstrapping WordPress.

Our plugin must follow the boundary rule

This package cannot help us if our business logic calls WordPress functions directly. The adapters are only useful when our plugin is structured so that service classes receive their dependencies through the constructor as contracts.

The rule: WordPress function calls (get_option, add_action, wp_remote_post, etc.) belong only in the thin adapter classes that implement the contracts. Every other class must call only the interface, never WordPress.

If we call get_option() inside a service, that service requires WordPress to exist and cannot be unit tested. The testing adapters in this package will have no effect.

See docs/testing-guide.md for the full structure, a wrong-vs-right example, PHPUnit setup, and a checklist.

Installation

Install as a dev dependency during development:

Copy the source into our plugin at build time:

This copies src/ and psr/log into lib/wp-adapter/ inside our plugin. Load it from our plugin's main file:

Strip vendor/ before distributing. lib/ ships with the plugin. See Direct-load distribution for the full workflow.

Wiring production adapters

Unit testing without WordPress

Swap in the in-memory testing adapters. No WordPress bootstrap required.

PHPUnit bootstrap (tests/bootstrap.php)

One line. Composer's autoloader includes devuri/wp-adapter and psr/log. All contracts and testing adapters are available. No WordPress, no WP_TESTS_DIR.

PHPUnit config (phpunit.xml.dist)

defaultTestSuite="Unit" ensures vendor/bin/phpunit never loads the integration suite. Integration tests (those that require WordPress) must be marked @group integration and run explicitly:

See examples/plugin-wiring/ for a complete, runnable example with service class, plugin class, and tests.

Testing adapters

All testing adapters live in AdapterKit\Core\Testing\ and are public, versioned API.

InMemoryOptionStorage

InMemoryTransientStorage + FrozenClock

MockHttpClient

RecordingHooks

RecordingLogger

MockEnvironment

Contracts

Six interfaces in AdapterKit\Core\Contracts\. Our plugin code depends only on these.

Contract Production adapter Testing adapter
HooksInterface WordPressHooks RecordingHooks
OptionStorageInterface WordPressOptionStorage InMemoryOptionStorage
TransientStorageInterface WordPressTransientStorage InMemoryTransientStorage
EnvironmentInterface WordPressEnvironment MockEnvironment
HttpClientInterface WordPressHttpClient MockHttpClient
ClockInterface SystemClock FrozenClock

LoggerInterface is Psr\Log\LoggerInterface. NullLogger and WordPressDebugLogger are the production implementations.

Shared value types

PluginContext — immutable plugin metadata populated once at bootstrap.

Result — shared return type for service methods.

KeyBuilder — prevents option/transient/hook naming drift.

Direct-load distribution

WordPress plugins are distributed as ZIP files without a Composer runtime. WP Adapter supports this out of the box.

Development workflow:

wp-adapter-copy copies src/ and a PHP 7.4-safe copy of psr/log into lib/wp-adapter/. The init.php entry point registers two PSR-4 autoloaders — one for AdapterKit\Core\ and one for Psr\Log\ — so no Composer is needed on the end user's server.

Do not use a class_exists guard:

Namespace-per-plugin scoping is deferred to a future build step.

Requirements

PHP 7.4, 8.0, 8.1, 8.2
WordPress No minimum enforced
Dependencies psr/log ^1.1 (runtime)

The package is deliberately PHP 7.4 compatible throughout. mixed type hints, constructor property promotion, union types, and all other PHP 8.0+ syntax are forbidden in src/.

Further reading

License

This project is licensed under the MIT License. See the LICENSE file for details.


All versions of wp-adapter with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0 || ^8.1 || ^8.2
psr/log Version ^1.1
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 devuri/wp-adapter contains the following files

Loading the files please wait ...