Archives


Master Symfony2 fundamentals

Be trained by SensioLabs experts (2 to 6 day sessions -- French or English).
trainings.sensiolabs.com

Discover the SensioLabs Support

Access to the SensioLabs Competency Center for an exclusive and tailor-made support on Symfony
sensiolabs.com

Fabien Potencier
Symfony2 Components as standalone Packages
by Fabien Potencier – July 08, 2012 – 8 comments

Each Symfony Component has been available as a standalone "package" for a very long time, but this is the first time I post something about this on this blog. That's because the way it was done was quite experimental... until recently.

Why is it useful? Let's say you have a project that does not use Symfony, the full-stack framework, but you still want to rely on a few Symfony Components like YAML, Console, and Process for instance. In that case, instead of depending on the main symfony/symfony code, your project can just depend on these specific components. If you are using Git submodules, just reference the repositories found on Github. If you are using Composer, and you should, just reference the components you rely on in your composer.json file:

{
    "require": {
        "symfony/yaml": "2.1*",
        "symfony/console": "2.1*",
        "symfony/process": "2.1*"
    },
    "minimum-stability": "dev"
}

The code found in these standalone Git repositories is synchronized with the main code found in the official Symfony repository. It works by "splitting" the main repository into many small ones thanks to the new subtree Git command. But until now, the process was fuzzy at best and unfortunately not very reliable.

First, because we have many things to extract. As of today, we have more than 60 different splits: 30+ components/briges/bundles for two versions, 2.0 and master. But soon, we will have 90 differents ones as we will branch 2.1. And of course, the more commits we have, the longer the process is (the master branch has 10,000+ commits).

Then, because we don't use the subtree command in the canonical way. As we don't want to pollute the main repository with information about the split, we need to start over each time we split. And splitting the whole repository from scratch for the 60 different splits takes at least 7 hours.

Because of these issues, the splits were only updated from time to time (every French night at most). But two weeks ago, I took a whole day working on optimizing the process and I've integrated the split with the Github push hook mechanism so that we only split the components involved in a push.

The new version has been online for the last week and the Components are now updated 1 or 2 minutes after some changes are pushed to the Symfony component. Unfortunately, we have had one force push during that time due to a bug in the Git subtree command (I haven't found the time to submit a bug report yet).

The good news is that the Symfony component repositories are now updated in near real-time with the main Symfony repository.

Comments RSS

  • Bernhard Schussek
    #1 Bernhard Schussek said on the 2012/07/08 at 16:52
    Great, thanks Fabien! :)
  • Igor Wiedler
    #2 Igor Wiedler said on the 2012/07/08 at 16:57
    Glad to hear that the splitting is becoming more robust.

    Is there any chance you could share the subtree script? I have 2 projects that need tags and branches to be split and would appreciate not having to re-solve this problem.
  • Loïc Chardonnet
    #3 Loïc Chardonnet said on the 2012/07/08 at 18:19
    Why are the components in synchronised in the main repository? Wouldn't it make more sense if they were simple dependencies?

    I'm sure you thought this through and have a good reason for doing it that way, I just want to know it :) .
  • Tal Ater
    #4 Tal Ater said on the 2012/07/09 at 07:43
    If you're looking for help using standalone Symfony 2 components in your own project, I've written a step-by-step tutorial on the subject, using the console component as an example: http://talater.com/symfony_console_component/
  • Pierre Minnieur
    #5 Pierre Minnieur said on the 2012/07/09 at 09:55
    Nice, thank you for your good work Fabien!
  • Beau Simensen
    #6 Beau Simensen said on the 2012/07/12 at 19:17
    Great news that the components are being updated more quickly. I'd like to see how these subtree splits are being managed. :)
  • David Grudl
    #7 David Grudl said on the 2012/07/18 at 15:38
    I've got the same question as #3 Loïc Chardonnet. Why did you choose to have one repository instead of per-components repositories with own issue trackers, pull requests, etc?
  • Lukas Kahwe Smith
    #8 Lukas Kahwe Smith said on the 2012/07/19 at 13:53
    Remember this decision predates composer. But the original reason was to make it easy to test everything as one. This includes being able to test the few (optional) dependencies between components, but also the Bundles.

    Now since the existence of composer this isn't as necessary anymore, but even then it would mean that running all tests would be a bigger effort.

    Finally changing this now would be fairly non trivial though IIRC we did figure out a way how in theory we could accept PR's coming in via the subtree split repos.