Today, Id like to annouce my new PHP Micro-Framework, Tiny.
Ha. Just kidding.
When I was building Forrst with Kyle, we knew that we didnt want to expose various primary keys, like post_id
s, and user_id
s, etc, on the site. The solution was to make URLs that looked like http://forrst.com/posts/Poly_Mantis-GFC.
We used a library from our friend, Jacob, that allowed us to obfuscate primary keys simply by base62
encoding them. I find myself using this library constantly, constantly copying and pasting from Kyles github account, where the code has been sitting untouched for literally years. I finally made it composer-installable.
You can find it here. I hope you can find it as useful as I do.
edit: Just to clarify, the tiny-ified ID wasnt stored anywhere, it was always calculated. We used methods something like:
class Post {
public function getUrl() {
return $this->getSlug() . - . $this->getTinyId();
}
}
edit 2: This could also be used to build something like a URL shortener, as $tiny->to(99999999);
would actually output jpWDw