Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

Don’t use illuminate/support in framework agnostic packages

In our framework agnostic packages we sometimes pull in illuminate/support. This package that’s part of the core of Laravel provides some nice string and collection functions. But unfortunately a lot of other stuff gets pulled in as well.  In a post on his blog Matthew Allen explains the downsides of requiring illuminate/support.

A lot of framework agnostic Composer packages (PHP) pull in illuminate/support, which contains helper functions and general purpose code used by the Laravel framework. Usually it’s because the support package has nice helper functions like array_get, or because of the nice collection class.

The helpers functions are nice, but I don’t think developers appreciate the ramifications of choosing to pull that package in. Everyone is afraid to get criticized for reinventing the wheel, so packages are pulling in 6000+ lines of code to avoid writing isset($arr[$k]) ? $arr[$k] : null themselves.


One of the most useful functions of illuminate/support is the Collection class. In a thread on Reddit Taylor Otwell, the creator of Laravel, seems to agree that requiring illuminate/support isn’t a good idea and that the Collection class could be extracted to it’s own package. Let’s hope that’ll happen in the near future.

In the new major versions of our framework agnostic packages we’ll swap out illuminate/support in favor of packages like the ones mentioned at the end of Matthew’s post.

EDIT: Meanwhile Tighten has released a Collections-only split from Laravel’s Illuminate Support.

Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band.