We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: A simple php class that can be used to build an entire web application framework
Homepage: http://72squared.com/scratchpad/
Clone URL: git://github.com/72squared/grok-php.git
name age message
file LICENSE Fri Jun 13 07:56:53 -0700 2008 changing the license to BSD [John Loehrer]
file README Thu Jun 12 21:14:54 -0700 2008 updatng the readme file to match the new api. [John Loehrer]
file TODO Fri Jun 13 08:52:29 -0700 2008 updating some comments. [John Loehrer]
directory examples/ Thu Nov 06 14:39:44 -0800 2008 more fixing on the regex url completion [John Loehrer]
file grok.php Tue Oct 28 11:12:04 -0700 2008 trying to finish up scratchpad example. [John Loehrer]
directory tests/ Mon Jul 28 16:55:56 -0700 2008 found a few errors or extraneous lines of code. [John Loehrer]
README
GROK

NAME
    Grok - a lightweight application framework for PHP

SYNOPSIS
    Most applications can be summarized as some variation on: 
        
        INPUT -> PROCESS -> OUTPUT
        
    Grok allows us to package up our arguments and pass them to a php include file and 
    retrieve the output. Some sample code might more easily to explain.
        
        $input = new Grok;
        $input->arg1 = 'test';
        $output = $input->dispatch('/path/to/file.php');
    
DESCRIPTION
    Grok at its most simple is a just a way to pass arguments in a reliable way to a php include.
    The class is able to both act as a container and as a dispatcher. In this way, we can reduce
    an entire application down to this formula:
        INPUT -> PROCESS -> OUTPUT
    Because one grok can call another grok, you can simplify complex tree of decisions into a well
    organized and reusable library of processing instructions.
    here is a simple example:
        
        $output = Grok::instance()->dispatch('/path/to/file.php');
        
    This command would find a file and include it.
    Each include becomes the body of an anonymous function. 
    
    Because grok is a container, i can assign stuff to a grok. These become arguments to the include. 
    When I dispatch it, I can access the assigned variables using syntax like: $this->myvar.
        
         Grok::instance(array('greeting'=>'hi'))->dispatch('test.php');
         
    inside the test.php file, i can access the greeting variable by doing:
        
        return $this->greeting;
        
    because dispatch also returns the response from the included file, the dispatch method can act
    just like a function.

DEPENDENCIES
    Grok was built for php5 or greater. To use Grok, just include the single grok.php file at the
    root of this directory. The file can be copied to any location and used as is. It needs no 
    customization. You don't need any other files. All the rest of the files in this project are 
    either tests or examples. The entirety of grok is contained in one very tiny php file.
    
AUTHOR
    John Loehrer <john@72squared.com>
    Send bug reports or comments to the above address.
    For more information, see the Grok homepage at http://github.com/72squared/grok-php/wikis