Le 02/07/13 18:30, Jeroen De Dauw a écrit :
Over the past few months a number of people have been poking at Composer [0] support for MediaWiki [1]. Today I had a look at this and found that though we are close to getting this to work, there are a few remaining problems to be tackled.
<snip>
- MediaWiki needs to load the composer autoloader when present.
- Installing extensions leaves the composer.json file modified.
- Not clear how to best install an extension
<snip>
Hello,
At first, thank you Jeroen from bringing this topic there and for all your investment on Composer =)
== creating a project the composer way ==
I talked a bit with #composer people (there are some available during European business hours). Here is a rough summary of my conversation with them this morning.
Composer being a dependency manager for your project, if you create a wiki locally you should create your own composer.json then require mediawiki/core and your extensions. IE MediaWiki itself would just be a dependency for your site project. So the process would be something like:
mkdir mysite && cd !:1 composer init -n --name=hashar/mysite --stability=dev
// Then install MediaWiki composer require mediawiki/core:dev-REL1_21
// And the abuse filter extension with its dependencies: composer require mediawiki/abuse-filter:dev-REL1_21
You end up with the following hierarchy:
/extensions/AbuseFilter /extensions/AntiSpoof /vendor/composer /vendor/mediawiki/core
The vendor/autoload.php is supposed to be required in your site and you would get everything you need. MediaWiki core does not provide an autoload entry in its composer.json.
== custom bundle ==
I have been pointed to https://github.com/symfony/symfony-standard which is a basic application making use of the Symfony framework. It has a few dependencies one of them being symfony/symfony (the full framework).
If one wanted to update the 'upstream' framework or ship additional dependency, he would just have to edit the symfony-standard composer.json and add them there.
== Composer hooks ==
Seldaek on IRC pointed to Composer hooks such as pre-update-cmd and pre-install-cmd. They could be used in MediaWiki core composer.json to load an extensions.json and inject dependencies on the fly. This way people could git clone mediawiki/core and then edit their local json to add extensions they want.
Some basic doc is at http://getcomposer.org/doc/articles/scripts.md
== Embedded Composer ==
The idea is to get Composer inside your application this way it can fetch the dependencies it needs.
Doc: https://github.com/dflydev/dflydev-embedded-composer#why-would-i-want-to-emb...
Presentation: http://srcmvn.com/blog/2013/05/23/symfony-live-2013-portland-embedded-compos...
If we want to do it the composer way, MediaWiki should be a standalone framework that you install under vendor and don't care much about. Then you could add to your project the extensions you need. Ideally your /index.php would be something like:
<?php require 'vendor/autoload.php' $wgSomeFeature = 'bah';
new MediaWiki()->run();