diff --git a/README.md b/README.md index f9b1805..e83a2fd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,33 @@ module-installer-plugin ======================= -module-installer-plugin +*This package is in development and may be subject to change. It is published to enable testing and feedback only.* + +This is a plugin for [Composer](http://getcomposer.org/) that allows XOOPS 2.6 modules to be managed by composer. Managing XOOPS modules with composer enables dependency management for modules, as modules can require other libraries, or even other modules. + +To use this plugin, your module should include a type property of **"xoops-module"** in its `composer.json`, and it should require **"XOOPS/module-installer-plugin"** as in the following example. + +```JSON + { + "name": "geekwright/dummy", + "type": "xoops-module", + "description": "XOOPS dummy module for testing", + "require": { + "XOOPS/module-installer-plugin": "~1.0" + } + } +``` + +The package contents will be installed in the modules directory, in a subdirectory of the same name as the module package. See [geekwright/dummy](https://github.com/geekwright/dummy) for a simple example of a module enabled for composer management. + +The `composer.json` of the main xoops-library package needs to set the filesystem path to the XOOPS modules directory in the "extra" property as shown here: + +```JSON + "extra": { + "xoops_modules": "/home/user/htdocs/modules/" + } +``` + +Normally, the XOOPS installer will have adjusted this setting during installation. + +The composer install process only makes the module available to XOOPS. Traditional module installation and configuration are still accomplished in the XOOPS system adminstration area. diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..3e32cbe --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "XOOPS/module-installer-plugin", + "description": "Install XOOPS modules using Composer", + "keywords": ["xoops", "installer"], + "type": "composer-plugin", + "license": "MIT", + "autoload": { + "psr-4": {"Xoops\\Composer\\": "src/"} + }, + "extra": { + "class": "Xoops\\Composer\\ModuleInstallerPlugin" + }, + "require": { + "composer-plugin-api": "1.0.0" + }, + "replace": { + "geekwright/module-installer-plugin": "1.0.*" + } +} \ No newline at end of file diff --git a/src/ModuleInstaller.php b/src/ModuleInstaller.php new file mode 100644 index 0000000..df4ed94 --- /dev/null +++ b/src/ModuleInstaller.php @@ -0,0 +1,45 @@ +getName()); + + $xoops_modules = '../modules/'; + + $extra = $this->composer->getPackage()->getExtra(); + if (isset($extra['xoops_modules_path'])) { + $xoops_root = $extra['xoops_modules_path']; + } + + return $xoops_modules . $moddir[1]; + } + + /** + * supports - determine if this supports a given package type + * + * @param string $packageType package type name + * + * @return boolean true if packageType is supported + */ + public function supports($packageType) + { + return 'xoops-module' === $packageType; + } +} diff --git a/src/ModuleInstallerPlugin.php b/src/ModuleInstallerPlugin.php new file mode 100644 index 0000000..e1f1abc --- /dev/null +++ b/src/ModuleInstallerPlugin.php @@ -0,0 +1,27 @@ +getInstallationManager()->addInstaller($installer); + } +}