Download the PHP package veronalabs/rabbit without Composer
On this page you can find all versions of the php package veronalabs/rabbit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package rabbit
Rabbit Framework - A modern way of building WordPress plugins.
About
Rabbit Framework is a modern framework designed to be a solid foundation for your WordPress plugins. the project is based on Backyard
Benefits
- Dependency injection container & service providers.
- template that helps you load the view easily.
- OOP Nonces wrapper & Factory methods.
- Caching helpers.
- HTTP Redirects with admin notices flashing.
- Macroable classes.
- LoggerWP
- Illuminate Database (Eloquent)
Requirements
- PHP 7.4 or higher.
- Composer
Usage
Plugin header fields
When creating a WordPress plugin, you are required to add header fields to your plugin's entry file. The Rabbit framework requires 1 additional field: Plugin Prefix
.
The Plugin Prefix
field is used by the framework to automatically define constants about the plugin.
Load Composer autoloader
Copy and paste the code below right after the header fields to load all the dependencies of your plugin, including the Rabbit framework.
Create a new Application instance
Every Rabbit powered plugin must create an instance of a Rabbit Application. The application is responsible for the loading of the plugin.
Create a new application instance by using the get()
method.
The plugin container
The framework handles a plugin through the Plugin
class. The Plugin
class is an extension of the PHP League dependency injection container. The container is responsible for the loading of configuration files, the registration & booting process of service providers and more.
Load your plugin into the application
After the instantiation of a Rabbit Application, you need to load your plugin into the application via the loadPlugin()
method.
The loadPlugin()
method takes 3 arguments, the third is optional.
- The path to the plugin.
- The path to plugin's entry file.
-
The name of the folder that holds the configuration files.
$myPlugin = $myPlugin->loadPlugin( DIR, FILE, 'config' );
The loadPlugin()
method returns the Plugin
container. You will then use the container to add functionalities to your plugin.
Configuration files
Configuration files provide an easy way to set options required by parts of application to work. Values can then be easily accessed by the plugin. A configuration file returns an associative array.
Use the config()
method to access values. Keys use dot notation starting with the name of the configuration file. Take a look at the example below:
File: config/plugin.php
In order to access the my_key
value, you need to call the config()
method this way:
Configuration files are used by some features provided by Rabbit.
Add service providers
Service providers in Rabbit are used to add functionalities to your plugin. Providers can be loaded by using the addServiceProvider()
method of the container class.
The activation & deactivation hook
Activation and deactivation hooks provide ways to execute actions when the plugin is activated or deactivated. If you're familiar with these hooks, you may remember they are called with the register_activation_hook
and register_deactivation_hook
functions.
In Rabbit you can register the activation and deactivation process by using the onActivation
and onDeactivation
methods of the Plugin
class. Both methods use a Closure as argument.
Boot the plugin
Use the boot()
method of the Plugin
class to boot your plugin. The boot()
method uses a Closure that allows you to add more functionalities to your plugin.
When booting, the plugin boots the registered service providers on the plugins_loaded
hook.
To boot your plugin use the following snippet:
Load plugin textdomain
If your plugin requires localization, you can use the loadPluginTextDomain
method inside the boot
method. The framework will use the information in your header fields to set the correct textdomain and languages folder path.
Include files
The Rabbit framework comes with an easy way to include()
files in your WordPress plugin. Use the includes()
method of the Plugin
class to include files from a specific folder. Files are loaded alphabetically.
The example above will automatically include *.php files from the includes
subfolder of your plugin.
Example entry file
Example plugin
There is an example of using the Rabbit Framework in this repository
License
Distributed under the MIT License. See LICENSE
for more information.
All versions of rabbit with dependencies
caseyamcl/configula Version ^3.1
illuminate/database Version ^8.61
illuminate/macroable Version ^8.7
laminas/laminas-diactoros Version ^2.5
laminas/laminas-escaper Version ^2.7
laminas/laminas-form Version ^2.15
laminas/laminas-i18n Version ^2.11
laminas/laminas-view Version ^2.11
league/container Version ^3.3
symfony/finder Version ^5.1
symfony/http-foundation Version ^5.1
veronalabs/logger-wp Version ^1.0