-
-
Save augustohp/2256112 to your computer and use it in GitHub Desktop.
Seamless Respect Framework
This file contains 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 | |
/** | |
* 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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems to already work. Am I right?