Util.php

Download Link: Download from GitHub

Please check it out, and feel free to submit issue reports, pull requests or fork it. I’ve received over 50 pull requests, with 90+ forks and 750+ stars on GitHub!

Overview

I just released my latest project, util.php to GitHub. Util.php is a single file that you can include in any of your projects without worrying about conflicts, since it’s entirely contained within the class util. The project includes dozens of functions (Over 40 right now) that most developers either need or use very frequently. It’s especially useful for small one-off projects that don’t warrant a framework that would normally include these methods.

It includes an extremely powerful alternative to print_r/var_dump that can be executed on variables of any type, and will show you the variable’s type, size, contents and more depending on the type of variable. It supports displaying arrays and objects, and includes some JavaScript that allows you to expand/collapse nested array elements within the variable. Here’s a screenshot of the function, util::var_dump( $var ):

util::var_dump() in action

The library also includes functions like array_pluck, array_first, array_last, get_var/post_var/request_var/etc (Retrieves a value from the superglobals but lets you specify a default if they aren’t set). If you’re interested in a complete list of the functions, take a look at the documentation I wrote.

The project includes a suite of unit tests as well.