Core Function Library
Current Version:
1.5 (maybe?)
Goals:
- 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!
Modules:
- 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)
Note, this is still actively being messed around with. The code exists, in so many forms. I should put it up on github or somewhere soon.
I -do- also have a loose front-controller pattern framework designed around it as well.
Also I have to say that Drupal implements a lot of these concepts nicely under the hood; the core of Drupal has a lot in common with what I was aiming for.
I am on the fence if I prefer WordPress' approach to extending using actions/filters, or if I like Drupal's hook system. Seems like a lot of overhead for Drupal to have to check if a function exists, rather than the WP approach of defining the actions ahead of time in the stack.
Who knows. I am burnt out right now, but I do want to keep this going as a background hobby. The functions themselves seem quite rock solid, I am just having design "back and forth" in my head on the most appropriate and separated way to isolate tying it in to a framework that can be developed against, as opposed to just a bunch of functions in include files.