Table of Contents
Plugins
Primer
The new plugin concept of Phile is a little bit different to pico, but also easy to understand. A lot of logic follows the concept convention over configuration, so please read the following list of conventions.
For another example of all these conventions, take a look at the example plugin.
Basic Folder Setup
plugins/ // Phile's plugin-folder
mycompany/ // [1]
myCoolPlugin/ // [2]
Classes/
Plugin.php // [3]
config.php // [4]
-
Your Plugin requires its own vendor and package folder under the
plugins/
folder:- [1] The name of the vendor folder must be lowercase like
mycompany
- [2] The name of the package folder must be lowerCamelCase like
myCoolPlugin
- [1] The name of the vendor folder must be lowercase like
-
Within your plugin folder you need at least two files:
- [3]
Classes\Plugin.php
this file contains yourPlugin
class (see below) - [4]
config.php
this file must return an array.
- [3]
[3] Plugin Class
Here's a barebone Plugin.php
:
<?php
namespace Phile\Plugin\Mycompany\MyCoolPlugin;
class Plugin extends \Phile\Plugin\AbstractPlugin { }
The filename is always Plugin.php
and the class name Plugin
. The class must extend \Phile\Plugin\AbstractPlugin
.
Every plugin lives in its own namespace Phile\Plugin\<vendor>\<package>
:
- The namespace always starts with
Phile\Plugin
- The namespace ending must match the folder setup:
<vendor>
in lowercase must be the vendor folder[1]
<package>
in lowerCamelCase must be the package folder[2]
So in this case Phile\Plugin\Mycompany\MyCoolPlugin
. Every additional class within this namespace and placed into Classes/
is autoloaded.