Created
October 4, 2012 05:25
-
-
Save toopay/3831630 to your computer and use it in GitHub Desktop.
Juriya App Socket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'Juriya/Juriya.php'; | |
use Juriya\Juriya; | |
use Juriya\Collection; | |
use Juriya\Request; | |
use Juriya\Controller; | |
use Juriya\ResponseHttp; | |
Juriya::registerAutoloader(); | |
class HelloController extends Controller { | |
public function executeHttp($arg1 = NULL, $arg2 = NULL) | |
{ | |
$name = empty($arg2) ? 'World' : $arg2; | |
return new ResponseHttp(200, $name); | |
} | |
} | |
$routes = new Collection(array('APP' => array( | |
'default' => array('controller' => 'HelloController', | |
'arguments' => array('hey', '/^[a-zA-Z0-9_:@\-\s]+$/')), | |
))); | |
$launcher = new Juriya(compact('routes')); | |
$launcher->setEnvironment('development'); | |
// This is the starting point of begin request process. | |
// Here we tell the framework that we want | |
// to listen the request from global variables($_SERVER, $_REQUEST) | |
$request = Request::fromGlobal(); | |
// Someone could change above statement into : | |
// | |
// $request = Request::factory('home', array('hey', 'Juriya'), 'http'); | |
// | |
// Which is also equals with more verbose instantiation : | |
// | |
// $config = new Collection(array( | |
// 'path' => array('home'), | |
// 'socket' => '\\HelloController', | |
// 'arguments' => array('hey', 'Juriya'), | |
// 'tunnel' => 'http', | |
// )); | |
// $request = new Request($config); | |
// | |
// By setting each request parameters (path, socket, arguments and tunnel), | |
// the framework will not listen the global variables anymore. | |
$launcher->execute($request); | |
// After the launcer execute the request, this point could considered as after request point. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment