Principles of PHP Package Design

Posted on by Matthias Noback

Amsterdam PHP - Principles of Package Design

Yesterday I presented "Principles of PHP Package Design" at the monthly meetup of the AmsterdamPHP usergroup. This was quite an experimental presentation. I had prepared it on the same day actually, though I had been gathering the contents of it for several weeks.

Package design is a subject I'm very much interested in and you can be sure to hear more from me about it. Actually, I started writing a book about it! If you're interested too, sign up on leanpub.com/principles-of-php-package-design.

Cover of Principles of PHP Package Design

By the way, these are the slides I used yesterday:

PHP Talk AmsterdamPHP Leanpub Principles of Package Design slides
Comments
This website uses MailComments: you can send your comments to this post by email. Read more about MailComments, including suggestions for writing your comments (in HTML or Markdown).
Steve Ellis

This was really interesting, particularly the discussion around monolog and its handlers. One of the guys in the audience made an interesting point about the handlers being dependent on mongolog via the interface, I guess it's feasible you might want to re-use a handler outside of monolog but it seems unlikely.

It did get me thinking about whether it's possible to totally de-couple two bundles that are related. For instance if you were building an e-commerce site and had a shopping cart package to store the user's shopping cart and a products package that provided CRUD operations for the products it seems like it would be a good idea for the cart package to provide an interface for anything that would like to be stored by the cart. So for example the product might implement a CartItemInterface provided by the cart package so the cart could keep track of it.

However by doing that the product package is now dependent on the cart package just for that interface definition even if you're not using the cart. Is there a better way of structuring those two packages so they don't have that dependency?