Hey everybody,
tl;dr - How do we add 3rd party libs to core: composer, git submodules, or copying the code?
So I have a question to discuss concerning MW core that I was hoping to get some feedback on: what is our policy on including third-party libraries in core?
To clarify, by policy I don't mean what factors do we take into account when deciding to include a library (although feel free to weigh in on that if you want to say something), but rather how one would go about doing it.
Here are the possibilities: 1) Use Composer to install dependencies 2) Use git submodules to store a reference to the repository 3) Copy the code and add a note somewhere of where it came from (If I am missing an option, please enlighten me.)
My opinion on the matter is that option 1 is probably the best, primarily because Composer was designed specifically for this purpose, and it is widely used and is unlikely to randomly disappear in the near future. Also, it makes the incorporation of these libraries trivial, since the autoloader will be automatically registered using Composer. However, the method is not without fault. A recent patch to core actually removed our composer.json file, in hopes of allowing MediaWiki sysadmins to make their own custom composer.json file so that extensions could be installed that way. Which is more important: better maintenance of core dependencies, or allowing easier extension installation? I don't know; that's for us to decide. I'm a bit conflicted on the matter because I really do want to make extension installation and management easier, but at the same time making sure the core itself is easy to use should probably be a higher priority.
The next option is pretty much similar to Composer in that you have a reference to some external code that will be downloaded when told to do so by the user. However, it's different from Composer in a number of ways: 1) when packaging tarballs, the code has to be downloaded anyway since submodules are git-specific, and 2) we have to manage the autoloader manually. Not too bad. If we decide the Composer option is not viable, I think this would be a good alternative.
I don't like the final option at all, but it seems to be our current approach. It's basically the same thing as git submodules except rather than having a clear reference to where the code came from and where we can update it, we have to add a README or something explaining it.
Also, just to clarify, this is not an out-of-the-blue request for comment. I am currently considering whether we might want to replace our HttpFunctions file with the third-party Guzzle library, since the latter is very stable, much much more functional, and a lot easier to use. However, this is out-of-scope for the discussion, so if you have an opinion on whether doing this is a good/bad idea, please start another thread.
*-- * *Tyler Romeo* Stevens Institute of Technology, Class of 2016 Major in Computer Science
Le 26/11/13 22:12, Tyler Romeo a écrit :
Hey everybody,
tl;dr - How do we add 3rd party libs to core: composer, git submodules, or copying the code?
Hello,
Thank you for bringing the subject there. A few folks are eager to have composer support for MediaWiki / extensions. I could not find anytime to work on it though :-(
Basically:
We tend to copy code and let it bit rot. At least there is no unexpected breakage.
Git submodules are a mess, needs to download code from github/whatever. And I tend to dislike submodules.
Result: we need a dependency manager Fact: Composer is more modern than pear
You should talk about it with Jeroen De Dauw. Since I talked about composer with him he converted all his extensions to it and seems to really want us to finally use composer for everything. He largely rewrote the lame page I have dumped a year ago at https://www.mediawiki.org/wiki/Composer
As usual with Jeroen, it is fully documented with nice examples and step by step tutorials. Definitely worth a read.
Also look at: http://www.bn2vs.com/blog/2013/11/24/introduction-to-composer-for-mediawiki-...
<snip>
Also, just to clarify, this is not an out-of-the-blue request for comment. I am currently considering whether we might want to replace our HttpFunctions file with the third-party Guzzle library, since the latter is very stable, much much more functional, and a lot easier to use. However, this is out-of-scope for the discussion, so if you have an opinion on whether doing this is a good/bad idea, please start another thread.
We invented the wheel but forgot to evangelize our classes or make them easy to reuse. So we are left with a bunch of code which is robust but has counterpart which are more modern / populars. I wish years ago we thought about code reusability and publishing our classes as easy to use modules. We would have ended up as a leading PHP group, that was not a priority though, the Wikimedia sites is.
You could start out a RFC to identify class that be replaced by a better third party libraries. I don't mind.
Symfony (a french PHP framework which is really spring for PHP) has a bunch of reusable components:
Among them: Console : could a bunch of our Maintenance class HttpFoundation : what you said, HTTP on rails Routing : do we have a router? ..
cheers,
On 11/26/2013 05:28 PM, Antoine Musso wrote:
Git submodules are a mess, needs to download code from github/whatever. And I tend to dislike submodules.
If we went with this option, we could just have straight Gerrit mirrors of any git repos we wanted to bundle. When we updated the submodule, we would also update the mirror.
That way there's no additional risk in the unlikely event someone tampers with the third-party GitHub repo (as long as we find out before updating our submodule/mirror).
Matt Flaschen
On Tue, Nov 26, 2013 at 5:28 PM, Antoine Musso hashar+wmf@free.fr wrote:
You could start out a RFC to identify class that be replaced by a better third party libraries. I don't mind.
Symfony (a french PHP framework which is really spring for PHP) has a bunch of reusable components:
Among them: Console : could a bunch of our Maintenance class HttpFoundation : what you said, HTTP on rails Routing : do we have a router?
Done. https://www.mediawiki.org/wiki/Requests_for_comment/Third-party_components
I'll continue on the search for more third-party components, but right now those listed seem like the main candidates (although even some of those listed would be really difficult to do and might not happen).
*-- * *Tyler Romeo* Stevens Institute of Technology, Class of 2016 Major in Computer Science
wikitech-l@lists.wikimedia.org