Core Function Library

October 9th, 2010 Leave a comment Go to comments

Current Version:
1.5 (maybe?)


  • Generic, optimized, reusable function library for most common needs.
  • "Smarter" database connectivity (only connect if needed, and only connect once.)
  • Time-tested "best of breed" methods for formatting, sanitizing, encoding.
  • Reduce the amount of code and resources needed for everything.
  • Strengthen code security, reusability by enforcing "elite" standards (no $_REQUEST, no magic quotes.)
  • Complement PHP's basic functions and simplify the complex ones.
  • Procedural code that should run on any PHP 5.2.x+ installation, no real upgrade path concerns.
  • CPU cycles are cheap - optimized for performance but safety first (check parameter types, bounds and sanity checking, typecasting to enforce them further) - a few syscalls to normalize and ensure safe processing are okay. PHP is shared-nothing and easy to scale.
  • 100% standalone and drop-in-place upgradeable.
  • Simply include one file, the rest is handled!


  • Cache (memcached right now)
  • Database (mysqli right now)
  • Data (encryption, decryption, sanitization)
  • Format (date, date/time, time, duration/difference) - output encoding and output formatting
  • Image Handling (scrubbing, thumbnailing)
  • Session Management (using database only right now, should be able to handle files, cache, or generic methods which are pre-configured - such as a read-through cache-to-database option)
  • User Management (out of scope? not generic enough?)
  • Utility functions (array sorting, XML to array, object to array, cleaned up and optimized versions of various useful functions collected around the net)
  • Validation functions (email, date, GUID, type checks)
  • Video Handling (conversion, identification?)

Upcoming changes:

  • [2.0] image_process() function that uses $config['images'] for configuration
  • [2.0] $config['databases'] to replace $config['datasources'], unless cache can be merged
  • [2.5] $config['databases']['foo']['type'] introduced - allow for mysql, mysqli, sqlite, mssql, etc.
  • [2.0?] Video conversion functions (best of breed)
  • [2.0?] Hook support, most likely modeled after Drupal
  • [2.0?] Confirm library is 100% standalone and drop-in-place upgradeable
  • Image watermarking support
  • [2.0] Function name cleanups to map better to their modules
  • Implement proper versioning
  • Adopt override style from FreeBSD for configuration items (default first, then override)