Plugins in Phar Archives ======================== This is a short guide on how to create single-file portable plugins using MakePhar. ## The workflow 1. Your application should export functions that can be called by the plugin on load, such as `myapp_plugin_register` in the example below. 2. Locate the .phar plugins to load, and `@include` them one at a time. 3. Process the plugins etc that has been registered from the successfully loaded .phar libraries. ## Example files ### src/plugin.php ~/myapp/myapp.phar while (readlink($root)) { $root = readlink($root); } // Finally get the directory (~/myapp) $root = dirname($root); Use this to locate your plugins. ### Find out if running from within a Phar You can easilly find out if running from within a .phar archive by calling `Phar::running()`. if (Phar::running()) { inside_phar(); } This doesn't make sense to use in phar plugins, as the main application can also be in a phar, in which case it will be true even for non-phar plugins.