One thing I really wanted to focus on when writing version 2 of phpScheduleIt was finding ways to keep the application open for extensibility. This led me to creating a pluggable framework that can be hooked into for certain operations. In this post I’ll explain a bit of the plugin structure and walk through how to configure and use plugins in phpScheduleIt.
Note: The version of phpScheduleIt at the time of writing is 2.2. While the exact details explained in this post may not apply to future versions, the core concepts will.
Let’s first explore how plugins are structured. phpScheduleIt ships with a /plugins directory. Within that are subdirectories for each supported plugin type. phpScheduleIt’s plugin architecture is mainly convention based. Each subdirectory within a plugin type represents a plugin. Taking the Authentication plugin type for example, we have ActiveDirectory, Drupal, and so on available to use for our authentication provider. The Authentication plugins directory currently looks like this:
Configuring and Activating a Packaged Plugin
phpScheduleIt comes packaged with a a few Authentication plugins, so we’ll continue using that for our example. Each plugin directory most likely will contain a default configuration file named something like subdirectory.config.dist.php. For example, ActiveDirectory will contain a file named ActiveDirectory.config.dist.php.
The first step is to remove the .dist part of the default configuration file. In our case, the file would end up being named ActiveDirectory.config.php.
Next, you need to adjust any configuration values to match your environment. For Active Directory, you may need to change domain controllers or administrative credentials.
Finally, you need to tell phpScheduleIt which plugin you want to use. Open up phpScheduleIt’s config file, located in /config/config.php and find the plugins section. By default, it looks like this:
$conf['settings']['plugins']['Authentication'] = ''; $conf['settings']['plugins']['Authorization'] = ''; $conf['settings']['plugins']['Permission'] = ''; $conf['settings']['plugins']['PostRegistration'] = ''; $conf['settings']['plugins']['PreReservation'] = ''; $conf['settings']['plugins']['PostReservation'] = '';
To use your configured plugin, just set the plugin value to the plugin name. Sticking with ActiveDirectory for Authorization, you’ll end up with this:
$conf['settings']['plugins']['Authentication'] = 'ActiveDirectory ';
And that’s it! phpScheduleIt will now use Active Directory when users log in.
Using a 3rd Party Plugin
The process for using a 3rd party plugin is nearly the same as the using a packaged plugin. The one difference is that the plugin needs to be ‘installed’ – which merely includes copying the full plugin directory into the plugin type directory. For example, if you are installing an Authentication plugin named FooAuth, simply copy the full FooAuth directory into /plugins/Authentication
Hopefully this process is nice and easy. Next we’ll talk about how to write our own plugins, starting with a pre-reservation plugin.