Create A Plugin

Create A Plugin

This wiki entry documents the creation of a plugin, geo_kit, that is still under development. While it is believed to be complete, this document is subject to revision.

Writing a plugin is much like creating a project with the exception that you must provide for installation and uninstallation of the plugin. There are some other differences that will be documented.

To write a plugin, create a project to hold it. I'm calling my project app_home. I am creating a port of the Rails Geo-Kit to Akelos. I don't know just how the Rails plugin works, but I assume that if the tests written for it are successful, then the plugin is working. I am going to translate the tests from Ruby to PHP. As I make each test, I'll make sure that it runs successfully. This procedure makes this a TDD (Test Driven Development) project.

The first thing we need to do is to create the main plugin directory, which will be referred to as plugin_home. In our case, this will be geo_kit. From the app_home directory, we write:

cd app/vendor/plugins
mkdir geo_kit

Documentation Files

The first files we need to create are plugin documentation. They will be placed in the plugin home directory. Details about them are here.

Plugin Specific Files

These are files that are not required by an ordinary application that are needed by a plugin. Details about them are here.

Plugin Application Files

config.php

Applications all contain a config.php in app_home/config. Some plugins, like geo_kit, need to add additional lines to it. The file that modifies it should be in plugin_home/config. This plugin will name it config.php, too. plugin_home/installer/geo_kit_installer.php needs to be able to find it. We'll illustrate this with the first two lines of the geo_kit script:

<?php
defined('GEOKIT_DEFAULT_UNITS') ? null : define('GEOKIT_DEFAULT_UNITS', 'miles');
defined('GEOKIT_DEFAULT_FORMULA') ? null : define('GEOKIT_DEFAULT_FORMULA', 'sphere');
?>

Plugin Code Scripts

The php scripts that do the work of the plugin are written in plugin_home/lib/geo_kit, where geo_kit is the name of your plugin.

Plugin Test Scripts

These scripts are for testing your plugin. Details about them are here.

 
plugin-create.txt · Last modified: 2008/09/18 16:15 by 82.103.221.224
 

The Akelos Framework was created by Bermi Ferrer and other contributors.
Potions of the code and documentation have been ported from Ruby on Rails.

The Akelos Framework is released under the LGPL license.

"Akelos", "Akelos Framework", and the Akelos logo are trademarks of Bermi Labs All rights reserved.

Wiki driven by DokuWiki