News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthias Noback:
There's no such thing as an optional dependency
April 11, 2014 @ 11:19:19

In his latest post Matthias Noback suggests the idea that there's no such thing as an optional dependency when it comes to working with packages and Composer.

On several occasions I have tried to explain my opinion about "optional dependencies" (also known as "suggested dependencies" or "dev requirements") and I'm doing it again: "There's no such thing as an optional dependency." I'm talking about PHP packages here and specifically those defined by a composer.json file.

So that everyone's on the same page, he starts with an example of a true dependency in a sample adapter class. He asks the usual question - "what's needed to run this code?" - and looking a bit deeper at the "suggested" packages. As it turns out, some of these dependencies turn into actual requirements when you need certain features of the tool. He points out that this is a problem with quite a few packages in the Composer ecosystem and proposes a solution - splitting packages based on requirements. He gives an example based on his adapter with a Mongo requirement split off into a "knplabs/gaufrette-mongo-gridfs" package that's more descriptive of the requirements.

0 comments voice your opinion now!
optional dependency composer packagist suggested package

Link: http://php-and-symfony.matthiasnoback.nl/2014/04/theres-no-such-thing-as-an-optional-dependency/

blog comments powered by Disqus

Similar Posts

Matthias Noback: Composer "provide" and dependency inversion

Rafael Dohms' Blog: Deploying a Symfony2 and Composer app on PagodaBox

Christopher Bledsoe's Blog: PHP Dependency Injection (Inversion of Control)

Hannes Magnusson's Blog: up2date PHP5.3 packages for Ubuntu

Zumba Engineering Blog: Enforce code standards with composer, git hooks, and phpcs


Community Events

Don't see your event here?
Let us know!


unittest security framework laravel library interview voicesoftheelephpant symfony extension series community language threedevsandamaybe api release podcast laravel5 opinion introduction version

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework