Added some new features

Added a couple of features: factory method, chaining, allowing PHP in a template, ability to set a base path, did a little bit of refactoring, and added unit tests. Hope you like :).