Symfony 6 Certification New exam with updated questions 100% online Show your expertise

Symfony2 Components as standalone Packages

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.

Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.


Great, thanks Fabien! :)
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.
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 :) .
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:
Nice, thank you for your good work Fabien!
Great news that the components are being updated more quickly. I'd like to see how these subtree splits are being managed. :)
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?
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.

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.