Skip to content

Instantly share code, notes, and snippets.

@augustohp
Forked from alganet/index.php
Created March 30, 2012 22:18
Show Gist options
  • Save augustohp/2256112 to your computer and use it in GitHub Desktop.
Save augustohp/2256112 to your computer and use it in GitHub Desktop.
Seamless Respect Framework
<?php
/**
* Example of usage of the "Respect Framework", that is actually
* just using one or more Respect components together.
*
* Using components in version 0.4.*
*/
use Respect\Validation\Validator as v;
use Respect\Rest\Router;
$router = new Router();
$router->get('/users/*', function($username){
return $username;
})->accept(array(
'text/html' => function($username) { return "<h1>".$username."</h1>"; },
'application/json' => 'json_encode'
))->when(function($username) {
return v::attribute('username')->alnum('_')->length(1,15)->validate($username);
});
@augustohp
Copy link
Author

Damn right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment