/workhorse

framework for URI-to-method translation

Primary LanguagePHP

workhorse

an MVC framework for web applications based on URI-to-method translation.

developed in eight minutes almost a decade ago (2003?), codenamed "workhorse," and then abandoned (codeigniter eventually came along and superceded it).

each controller is an extension of the Application class, which contains all of the input and output systems needed to invoke one controller feature per URI and produce a view.

there is a Command class which is created from user input with a small pattern matching system and then executed according to the methods of a subclass of Application.

view pages thus need only a couple lines of code, to create an application object and then run it immediately, however, any amount of processing could have been done first -- even with other application objects.

controllers work by simply naming the methods with the string the client is expected to request to invoke the method. e.g. the source code viewer demo page, source.php, supports the method "view", making the request URI domain.com/path/to/source.php/view, with whatever arguments as may be relevant following thereafter. mod_rewrite can be used to prettify the path to just source/view. to support this method, source.php creates a Source object, which extends Application but also has a method declared: public function view($filename). arguments are fed to the function from PATHINFO in the order they appear in the URI.

the tao demo shows an alternative use for the __default handler, which will be invoked when the segment of PATHINFO in the URL that is interpreted as the method name does not actually name a function that exists in the class (or is just not present in the URL).