Symfony Components: Sometimes Decoupled, Sometimes Not

Previously, on decoupling and dependencies, I said: "Some [Symfony] commenters were dissatsifed with my use of unit testing requirements to discover what a package really depends on, as opposed to what its composer.json file states."

I'm willing to allow that the Symfony commenters here might be right. Let's try looking at Symfony's claims and see how they stack up. Regarding the decoupling of their components, the Symfony website states:

Beside being a full-stack framework, Symfony is also a set of decoupled and standalone components.

What is a Component?

Symfony Components implement common features needed to develop websites. They are the foundation of the Symfony full-stack framework, but they can also be used standalone even if you don't use the framework as they don't have any mandatory dependencies.

That page then lists the following as their "decoupled" "standalone" components that "don't have any mandatory depedencies":

- BrowserKit             ~ EventDispatcher    ~ Routing
+ ClassLoader            + Finder             - Security
+ Config                 - Form               + Serializer
+ Console                + HttpFoundation     + Templating
+ CssSelector            - HttpKernel         ~ Translation
~ DependencyInjection    + Locale             ~ Validator
~ DomCrawler             + Process            + Yaml

After reviewing the master Github branches for the components' composer.json files, and in some cases the code itself, I conclude that Symfony's claim of "decoupled" "standalone" components is clearly true for 11 of those packages (marked with a + above) and clearly false for 4 of them (marked with a -). I think the claim is debatable for the remaining 6 components (marked with a ~) and I may take up that debate at some later time.

The 11 components for which Symfony's claim is clearly true are: ClassLoader, Config, Console, CssSelector, Finder, HttpFoundation, Locale, Process, Serializer, Templating, Yaml. These composer.json for these components has no "require" for another Symfony component, and my brief review of the codebase did not reveal any hidden dependencies.

The 4 components for which Symfony's claim is clearly false (i.e., composer.json notes at least one "require" for another Symfony component) are:

  • BrowserKit (requires DomCrawler)
  • Form (requires EventDispatcher, Locale, and OptionsReslover [which is not listed in the components])
  • HttpKernel (requires EventDispatcher and HttpFoundation)
  • Security (requires EventDispatcher, HttpFoundation, and HttpKernel)

As such, I think it is clearly false that all Symfony components are standalone and decoupled with no mandatory dependencies. Does having mandatory dependencies make it a bad project? Not at all. It just means their statement of "no mandatory dependencies" (and related statements) is not true for all the components listed.

Now, it may be that the Symfony folk have a different idea of what "decoupled" and "standalone" mean. Are they decoupled from the framework? Sure. But are they decoupled from each other? The answer appears to be "not always."

In comparison, all Aura packages (aside from the Framework package as previously noted) are fully decoupled from the framework composed of them, and also from each other. There no mandatory dependencies, and there are no suggested/optional/sometimes/maybe dependencies. Does that alone make it a good project? Not at all. It just means my claim about decoupled packages in Aura is completely true.

Are you stuck with a legacy PHP application? You should buy my book because it gives you a step-by-step guide to improving your codebase, all while keeping it running the whole time.