Difference between revisions of "Composer (PHP)"
m |
m |
||
Line 1: | Line 1: | ||
− | Some extensions of MediWiki are managed by composer. This tool is intended to manage dependencies and needed versions of MediaWiki extensions. It needs a basic configuration file (<code>composer.json</code> in the | + | Some extensions of MediWiki are managed by composer, a snmall PHP script. This tool is intended to manage dependencies and needed versions of software components, such as MediaWiki extensions. It needs a basic configuration file (<code>composer.json</code> in the wiki root folder) and installation or removal of extensions is ''done on the command line''. |
Documentation: | Documentation: | ||
Line 6: | Line 6: | ||
* https://packagist.org/search/ search any composer managed extension | * https://packagist.org/search/ search any composer managed extension | ||
* Composer itself: https://getcomposer.org/doc/ the very composer documentation | * Composer itself: https://getcomposer.org/doc/ the very composer documentation | ||
− | |||
− | Step 0: First install of PHP composer tool itself: | + | __TOC__ |
+ | |||
+ | |||
+ | Step 0: First install of PHP composer tool itself to a local shared <code>bin</code>-directory: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cd ~ # go to personal home directory | cd ~ # go to personal home directory | ||
Line 22: | Line 24: | ||
{ | { | ||
"require": { | "require": { | ||
− | "php": ">=5.3.2 | + | "php": ">=5.3.2" |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}, | }, | ||
"suggest": { | "suggest": { | ||
Line 53: | Line 49: | ||
== Add an extension == | == Add an extension == | ||
− | Read the documentation of the extension what kind of version you need, the extension’s documentation should describe it. | + | Read the documentation of the extension what kind of version you need and so forth, the extension’s documentation should describe it sufficiently. |
− | The following “require”-command will update your <code>composer.json</code> as well as install the extension including dependencies: | + | The following “require”-command will update your <code>composer.json</code> as well as install the extension including potential dependencies: |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
cd /var/www/path/to-wiki-root/ | cd /var/www/path/to-wiki-root/ |
Revision as of 20:42, 25 March 2015
Some extensions of MediWiki are managed by composer, a snmall PHP script. This tool is intended to manage dependencies and needed versions of software components, such as MediaWiki extensions. It needs a basic configuration file (composer.json
in the wiki root folder) and installation or removal of extensions is done on the command line.
Documentation:
- Composer (MediaWiki)
- Extensions supporting Composer (MediaWiki)
- https://packagist.org/search/ search any composer managed extension
- Composer itself: https://getcomposer.org/doc/ the very composer documentation
Step 0: First install of PHP composer tool itself to a local shared bin
-directory:
cd ~ # go to personal home directory
sudo curl -sS https://getcomposer.org/installer | php
sudo chown root:mwadmin composer.phar
sudo mv composer.phar /usr/local/bin/
Step 1: Manage your required extensions in file composer.json
in the root wiki folder. A basic setup is shipped usually by the Mediawiki installation. File composer.json
can look like:
{
"require": {
"php": ">=5.3.2"
},
"suggest": {
"ext-fileinfo": "More accurate file type detection for uploaded files",
"ext-mbstring": "Faster unicode handling",
"ext-wikidiff2": "Faster diff generation",
"ext-apc": "Speed up MediaWiki with opcode caching (before PHP 5.5)"
},
"autoload": {
"psr-0": {
"ComposerHookHandler": "includes/composer"
}
},
"scripts": {
"pre-update-cmd": "ComposerHookHandler::onPreUpdate",
"pre-install-cmd": "ComposerHookHandler::onPreInstall"
},
"config": {
"optimize-autoloader": true
}
}
Add an extension
Read the documentation of the extension what kind of version you need and so forth, the extension’s documentation should describe it sufficiently.
The following “require”-command will update your composer.json
as well as install the extension including potential dependencies:
cd /var/www/path/to-wiki-root/
sudo -u www-data php /usr/local/bin/composer.phar require 'mediawiki/semantic-maps' '3.1.3'
Update extensions
cd /var/www/path/to-wiki-root/
sudo -u www-data php /usr/local/bin/composer.phar update
Remove an extension
See https://getcomposer.org/doc/03-cli.md#remove
cd /var/www/path/to-wiki-root/
sudo -u www-data php /usr/local/bin/composer.phar remove 'mediawiki/semantic-maps'
Self Update of composer
sudo php /usr/local/bin/composer.phar self-update