PHPackages                             laegel/wp-plugin-maker - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. laegel/wp-plugin-maker

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laegel/wp-plugin-maker
======================

0.1.0(8y ago)019MITPHP

Since May 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Laegel/wp-plugin-maker)[ Packagist](https://packagist.org/packages/laegel/wp-plugin-maker)[ RSS](/packages/laegel-wp-plugin-maker/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

A WordPress OOP library
=======================

[](#a-wordpress-oop-library)

The goal is to normalize WP plugins structures to avoid dirty code and, by extension, bugs and security breaches.

Features
--------

[](#features)

### Better structure implies better code

[](#better-structure-implies-better-code)

This package focuses on the way the code in your plugin is structured. By default, a plugin generated (and processed) by [WP Plugin Maker CLI](https://github.com/Laegel/wp-plugin-maker-cli) looks like this:

```
my-plugin
|-- my-plugin.php
|-- require-admin.php
|-- require-cli.php
|-- require-front.php
|-- require-rest.php
|-- src
|   |-- Admin
|   |   |-- (classes)
|   |-- All
|   |   |-- (classes)
|   |-- CLI
|   |   |-- (classes)
|   |-- Front
|   |   |-- (classes)
|   |-- Rest
|   |   |-- (classes)
|   |-- Plugin.php
|   vendor
|   |-- (packages)

```

It splits the features you want to provide through your plugin into five parts: admin, CLI, front, REST and all. Each folder speaks for himself, and "all" concerns code that will appear in every part.

**What am I supposed to put in those folders?**Basically, your WP filters and actions declarations.

**Wait, I don't only have filters and actions in my plugin...**Though there are five defined folders/namespaces with specific behaviours, you can add any other folder to put your other classes (models, etc...) into them.

### Automatic filters and actions

[](#automatic-filters-and-actions)

**Okay, file structure is nice but what are those "require" files you have here?**As you may have noticed, those files are named from the parts previously evoked - except "all".

When defining a class method with "action\_" or "filter\_" prefix, it means you create respectively an action or a filter.

**How does it work? Should I just code?**Though this lib can seem to be magic, it is not. You'll have to use [WP Plugin Maker CLI](https://github.com/Laegel/wp-plugin-maker-cli) to automatize your filters/actions registrations by watching your plugin folder. So, when changes happen, your "require" files will be refreshed.

Your controllers will be parsed with reflection and every relevant action will be cached.

Here is a sample controller (src/Admin/Test\_Controller.php):

```
