Warning: file_put_contents(): Only 0 of 8322 bytes written, possibly out of free disk space in system/classes/filecache.php line 154
Warning: file_put_contents(): Only 0 of 303 bytes written, possibly out of free disk space in system/classes/filecache.php line 157
A Problem with the MicroPHP Movement - RedAlt

Ed Finkler recently published a "manifesto" concerning the need for lightweight PHP development libraries for small projects not needing the full weight of MVC frameworks that are so prevalent these days. These ideas and suggested libraries for use are now listed at MicroPHP.org. I agree with these sentiments for the most part, but I do have one concern that I've been unable to allay: There are no routers I can find that ascribe to the PSR-0 autoloader standard.

Basically, PSR-0 explains how PHP libraries can use namespaces and directory structures to ensure some means of compatibility. For example, if a library is in the namespace \fry\core\database then the SPL autoloader can expect to find it in a specific directory within the project structure. (More detailed explanation.) The problem is that most of the recommended libraries don't even use namespaces, much less adhere to the PSR-0 recommendations.

This is a problem because each of the router libraries has its own way of defining where things should be, or worse, none at all. Some of the smaller routers, like klien.php, contain the whole of their workings in a single file, rather than spreading the classes out into individual files like PSR-0 suggests. This itself isn't a problem at first, because you can include a separate autoloader yourself, but it does present some issues when you try to use those other libraries.

I suppose the recommendation of MicroPHP advocates is to simply include what you need when you need it. I guess that's fair. But I expect that any project that results from the binding together of small libraries will be an interesting puzzle to sort out, and adding endless includes to the top of the index.php that starts the project doesn't necessarily seem like the best way to handle dependencies.

As a result, I'm looking for a good router that includes an SPL Autoloader. I'd started re-writing microsite for this purpose, although I had done this prior to the MicroPHP manifesto, and there are some changes I'd like to make to improve my tiny framework's micro-ness. But microsite does include an autoloader and assumes a PSR-0 directory structure, which I feel is simpler than explicitly including all of the libraries.

If the intent is to make it easier to code small things faster, then I believe that a router implementation that supports autoloading of classes is the fastest means to implementation. Hopefully, more of these smaller libraries begin to include namespaces and support the PSR-0 directory structure.


There are no comments on this post.