Download the PHP package jascha030/wp-plugin-lib without Composer
On this page you can find all versions of the php package jascha030/wp-plugin-lib. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jascha030/wp-plugin-lib
More information about jascha030/wp-plugin-lib
Files in jascha030/wp-plugin-lib
Package wp-plugin-lib
Short Description Classes for Wordpress Plugin Development using more modern PHP and more OOP.
License MIT
Informations about the package wp-plugin-lib
WP Plugin Library for OOP
A backbone for utilizing
the Wordpress Plugin API
, using [email protected]
and OOP.
Getting started
Prerequisites
- Php
^7.4.*
- Composer
^2
- WordPress >= 5.5.0
Installation
Usage
The easiest way to explain usage is with an example of the main plugin file.
The name of the package might be deceiving, Plugin refers to the WP
Plugin API, which means that it can be used for either a plugin or a
theme. In this example we pretend to be building a plugin, but for a
theme we would just write our code in the theme's
functions.php
file instead of the main plugin file.
main-plugin-file.php
Hookables
The plugin revolves around classes implementing HookableInterface
or
one of it's extended interfaces. Hookables should only contain public
methods that are hooked to WordPress' filters or actions.
I recommend using the LazyHookableInterface
, classes implementing this
will only be constructed upon the first call to a hook containing one of
its methods.
Here's an example of a class Implementing LazyHookableInterface
:
TestingHookable.php
Providers
The standard container used is the Psr11 wrapper from
the pimple/pimple
package. Providers follow
pimple's ServiceProviderInterface
.
Testing
Included with the package are a set of Unit tests
using phpunit/phpunit
. For ease of use a composer script command is
defined to run the tests.
A code coverage report is generated in the project's root as cov.xml
.
The cov.xml
file is not ignored in the
.gitignore
by default. You are encouraged to commit the latest code
coverage report, when deploying new features.
Code style & Formatting
A code style configuration for friendsofphp/php-cs-fixer
is included,
defined in .php-cs-fixer.dist.php
.
To use php-cs-fixer without having it necessarily installed globally, a composer script command is also included to format php code using the provided config file and the vendor binary of php-cs-fixer.
License
This composer package is an open-sourced software licensed under the MIT License