You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
PHP Microframework for use with whatever you like. Basically just a fast routerwith nice syntax, and a cache singleton. Will add more things as I go, likeperhaps an extension system, autoloader and some other stuff to make developingin PHP less irritating than it currently is.
Routes are converted to regex and cached so this process does not need tohappen every request. Furthermore, the resolved route for a given URI is alsocached so on most requests thare is no regex matching involved.
There is also now the ability to mount apps on routes within apps, so one couldmake an administrator app, then mount it on the main app at /admin.
PHP presents an interesting challenge because due to it's architecture,everything has to be re-done each request, which is why I'm leveraging cachingwith tiny TTLs to share the results of operations like route resolutionbetween requests.
Note: PHP already has many of the features that many microframeworks have, suchas session handling, cookies, and templating. An aim of this project is toencourage the use of native functionality where possible or where it is good,but make some parts nicer or extend upon them to bring it up to scratch withthe way I like things.
Note: For maximum speed gains, use the XCache extension because that supportscaching of closures, unlike APC.
Goals
Make pretty much anything I/O related cached with XCache/APC(whichever is installed) in order to prevent excessive disk usage or pathsearching on lots of requests.
Provide a succinct syntax that means less magic and less code to readthrough and learn, without compromising speed or code length, by using nativePHP methods and features.
Promote a simple, flat way of building applications that don't needmassive levels of abstraction.
Encourage use of excellent third-party libraries such as Doctrine to preventdevelopers writing convoluted, unmaintainable code that people like me have topick up and spend hours poring over just to get an idea of what on earth isgoing on.
Define and document development patterns that allow for new developers toget up to speed quickly and write new code that isn't hacky.
Inspired entirely by Flask.
Requirements
PHP 5.3
XCache (preferred) or APC (still optional)
Requests pointed at file that you put the app in (eg.index.php).
require'ham/ham.php';$beans =newHam('beans');$beans->route('/',function($app) {return"Beans home.";});$app->onError(function(){return"Burnt Bacon.";},"Error message can go here.");$app->run();
Output:
/beans/
Beans home.
/beans/baked
Yum!
/
App home.
/definitely_not_the_page_you_were_looking_for
Burnt Bacon.
Have a gander at the example application for more details.
To-Dos
Nice logging class and logging support with error levels, e-mailing, etc.