Skip to content

Instantly share code, notes, and snippets.

@toopay
Created September 13, 2012 10:58
Show Gist options
  • Save toopay/3713571 to your computer and use it in GitHub Desktop.
Save toopay/3713571 to your computer and use it in GitHub Desktop.
Explicit Front Socket
<?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)
{
$content = $this->model->say($arg1, $arg2);
$response = new ResponseHttp();
$response->setCode(200);
$response->setHeaders(array('Content-Type' => 'text/html; charset=utf-8'));
$response->setContent($content);
return $response;
}
}
class HelloModel {
public function say($arg1 = NULL, $arg2 = NULL)
{
$hello = is_null($arg1) ? 'Hello' : $arg1;
$world = is_null($arg2) ? 'World' : $arg2;
return $hello . ' ' . $world;
}
}
$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');
$request = Request::fromGlobal();
$launcher->execute($request);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment