forked from xp-framework/xp-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
topics.scriptlets
Alex Kiesel edited this page Jun 7, 2012
·
7 revisions
The scriptlet.HttpScriptlet class is the base class
for any so-called scriptlet. A scriptlet is something that can serve
HTTP requests.
The simplest form of answering an HTTP request in XP Framework goes like this:
<?php
uses('scriptlet.HttpScriptlet');
class MyScriptlet extends HttpScriptlet {
/**
* Perform GET request
*
* @param scriptlet.HttpScriptletRequest request
* @param scriptlet.HttpScriptletResponse response
* @throws scriptlet.HttpScriptletException
*/
public function doGet($request, $response) {
$response->write('<html>
<head><title>Hello World scriptlet</title></head>
<body>
<h1>Hello %s</h1>
</body>
</html>
',
$request->getParam('name', 'World')
);
}
}
?>This code generates a HTML page that shows a headline "Hello World" or "Hello $something" when something was given as GET-parameter "name".
Override doPost() or any of the other methods named after HTTP
request types to serve these request types, as well.