Useful is a PHP non-framework. It's a collection use utility classes. Take what you want, leave the rest.

v0.3.0.1 2010-05-21 00:00 UTC

This package is auto-updated.

Last update: 2021-03-25 22:41:25 UTC


Useful is a PHP library collection with a focus on simplicity. Take what you want, ignore the rest.



Useful provides convenience that is not easily found anywhere else.

It solves common challenges that are not well addressed by the PHP language, common frameworks or popular libraries.


Useful can be used quickly without lots of reading and training.

Class hierarchy is flat. Each class does one thing. All classes are immediately useful to application developers.

Easy integration

Useful does not require you to do anything in one particular way.

It has few dependencies, and dependencies are clearly marked. Every class stands on its own and can be used on its own.


PHP 5 >= 5.4 or PHP 7; or PHP 5 >= 5.0 with special handling (see No namespaces below).

Most classes should work anywhere that PHP does. Exceptions are clearly marked.



Useful supports Composer. If you do too, great, install Useful using it and go.



You can clone from Github, or just copy in the files.

Clone from Github:


You can even paste in a single class; Useful classes have no interdependencies, so if you only want one just take it and use it.


Composer autoload

If you use Composer then Useful code will autoload automatically. All classes are in the \Useful namespace.


// Create a Useful Date object
$oDate = \Useful\Date::create('1999-12-31');

Include Useful's autoloader

// Load Useful autoloader directly

// Create a Useful Date object
$oDate = \Useful\Date::create('1999-12-31');

It's a simple PSR-4 autoloader for the \Useful namespace.

No namespaces: Legacy loader

Useful supports PHP 5 back to (in theory) 5.0 via its "legacy loading" system.

Note, the test suite requires PHP 7. Author has used parts of Useful on PHP 5.1. Your mileage may vary.

PHP 5.1-compatible SPL autoloader

// Load Useful legacy autoloader

// Create a Useful Date object
$oDate = Useful_Date::create('1999-12-31');

The legacy autoloader uses a classname prefix (Useful_Foo) instead of namespace (\Useful\Foo).

PHP 5.0 loader

PHP 5.0 does not have spl_autoload_register(). That's ok. The legacy loader can be used to load a class directly without namespace.

// Load Useful_Legacy_Loader class

function __autoload($sClass)
	// Try Useful legacy loader, it will return FALSE if not handled.
	// You could also just call this method directly for each class you want, without an autoloader.
	if (Useful_Legacy_Loader::loadClass($sClass)) {

	// ... whatever else you need to autoload

// Create a Useful Date object
$oDate = Useful_Date::create('1999-12-31');


Uses PHPUnit. Test coverage is [2019-04] @TODO very incomplete for some classes.