PHPackages                             veronalabs/rabbit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. veronalabs/rabbit

ActiveLibrary[Framework](/categories/framework)

veronalabs/rabbit
=================

A modern way of building WordPress plugins.

1.5(1y ago)15696↑50%3[1 PRs](https://github.com/veronalabs/rabbit/pulls)MITPHPPHP &gt;=7.2

Since Oct 5Pushed 1y ago4 watchersCompare

[ Source](https://github.com/veronalabs/rabbit)[ Packagist](https://packagist.org/packages/veronalabs/rabbit)[ Docs](https://github.com/veronalabs/rabbit)[ RSS](/packages/veronalabs-rabbit/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (17)Versions (26)Used By (0)

Rabbit Framework - A modern way of building WordPress plugins.
==============================================================

[](#rabbit-framework---a-modern-way-of-building-wordpress-plugins)

[![Total Downloads](https://camo.githubusercontent.com/b9f931d0c36040657734a12cd29bde87b102442e5dd8a05617541137bc1e475d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7665726f6e616c6162732f7261626269742e737667)](https://packagist.org/packages/veronalabs/rabbit)[![Latest Stable Version](https://camo.githubusercontent.com/1f67e878beae7d29a45a4693639a50d961d2eaa27a6f92be8912978dc5cadf7c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7665726f6e616c6162732f7261626269742e737667)](https://packagist.org/packages/veronalabs/rabbit)

About
-----

[](#about)

Rabbit Framework is a modern framework designed to be a solid foundation for your WordPress plugins. the project is based on [Backyard](https://backyard.sematico.com/)

Benefits
--------

[](#benefits)

1. Dependency injection container &amp; service providers.
2. template that helps you load the view easily.
3. OOP Nonces wrapper &amp; Factory methods.
4. Caching helpers.
5. HTTP Redirects with admin notices flashing.
6. Macroable classes.
7. [LoggerWP](https://github.com/veronalabs/logger-wp)
8. Illuminate Database (Eloquent)

Requirements
------------

[](#requirements)

1. PHP 7.4 or higher.
2. Composer

Usage
-----

[](#usage)

```
composer require veronalabs/rabbit
```

Plugin header fields
--------------------

[](#plugin-header-fields)

When creating a WordPress plugin, you are required to add [header fields](https://developer.wordpress.org/plugins/plugin-basics/header-requirements/) 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](/docs/constants) about the plugin.

```
/**
 * Plugin Name:     Example plugin
 * Plugin URI:      https://example.com
 * Plugin Prefix:   EP
 * Description:     Description
 * Author:          Alessandro Tesoro
 * Author URI:      https://example.com
 * Text Domain:     example-plugin
 * Domain Path:     /languages
 * Version:         0.1.0
 */
```

Load Composer autoloader
------------------------

[](#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.

```
if ( file_exists( dirname( __FILE__ ) . '/vendor/autoload.php' ) ) {
    require dirname( __FILE__ ) . '/vendor/autoload.php';
}
```

Create a new Application instance
---------------------------------

[](#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.

```
$myPlugin = Application::get();
```

The plugin container
--------------------

[](#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](https://container.thephpleague.com/). The container is responsible for the loading of configuration files, the registration &amp; booting process of service providers and more.

Load your plugin into the application
-------------------------------------

[](#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**.

1. The path to the plugin.
2. The path to plugin's entry file.
3. The name of the folder that holds the configuration files.

    $myPlugin = $myPlugin-&gt;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)

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.

```
$myPlugin->config( 'key' );
```

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`

```
