Download the PHP package wp-oop/containers without Composer
On this page you can find all versions of the php package wp-oop/containers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wp-oop/containers
More information about wp-oop/containers
Files in wp-oop/containers
Package containers
Short Description PSR-11 container implementations that wrap some WP features, for convenience and interoperability.
License MIT
Informations about the package containers
WP Containers
Details
PSR-11 container implementations that wrap some WP features, for convenience and interoperability.
Features
Retrieve sites by key
Retrieve site options by key
Retrieve site meta by key
Structured error handling
This solves the problem of inconsistent behaviour of native WordPress option-related funtions:
- retrieved options returned
false
for both afalse
value and when not found, making them hard to distinguish; - setting an option returned
false
for both failure, an when the value is the same as the curent value, often resulting in a false error.
This is no longer the case with the above containers: option operations succeed or correctly fail by throwing PSR-11 exceptions. Furthermore, the original behaviour of these exceptions has been extended to allow retrieval of the key that was not found (when applicable) and the container that failed the operation. This is optional, however, and depending simply on the PSR-11 exceptions will work as expected.
The set()
, has()
, and unset()
also throw ContainerExceptionInterface
on failure.
Wraps WP
The containers do not re-create the functionality to go around WordPress. Instead, they wrap native WordPress functionality,
so you can be sure that everything is done in the same way, all the hooks, such as option_*
or pre_update_option_*
, still work.
All versions of containers with dependencies
psr/container Version ^1.0
dhii/collections-interface Version ^0.3.0-alpha1