2017 © Pedro Peláez
 

library scriptlet

Scriptlets for the XP Framework

image

xp-framework/scriptlet

Scriptlets for the XP Framework

  • Sunday, July 15, 2018
  • by thekid
  • Repository
  • 16 Watchers
  • 0 Stars
  • 38,664 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 51 Versions
  • 8 % Grown

The README.md

Scriptlets for the XP Framework

Build Status on TravisCI XP Framework Module BSD Licence Required PHP 5.6+ Supports PHP 7.0+ Latest Stable Version, (*1)

Everything that runs in the web in the XP Framework, is a scriptlet, at the beginning. Every higher-class API is derived from the simple HttpScriptlet class: RestScriptlet, WorkflowScriptlet, ..., (*2)

The HttpScriptlet class

The scriptlet.HttpScriptlet class is the base class for any so-called scriptlet. A scriptlet is something that can serve HTTP requests., (*3)

The simplest form of answering an HTTP request in XP Framework goes like this:, (*4)

namespace com\example\web;

class HelloScriptlet extends \scriptlet\HttpScriptlet {

  /**
   * Perform GET request
   *
   * @param  scriptlet.Request $request
   * @param  scriptlet.Response $response
   * @throws scriptlet.ScriptletException
   */
  public function doGet($request, $response) {
    $response->write(sprintf('<!DOCTYPE html>
      <html>
        <head><title>Hello World scriptlet</title></head>
        <body>
          <h1>Hello %s</h1>
        </body>
      </html>',
      htmlspecialchars($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"., (*5)

Override doPost() or any of the other methods named after HTTP request types to serve these request types, as well., (*6)

Running it

Use the xp web runner to serve your scriptlet:, (*7)

$ xp web com.example.web.HelloScriptlet
[xpws-dev#7312] running localhost:8080 @ /path/to/web/project - Press <Enter> to exit

Now open http://localhost:8080/ in your browser., (*8)

The Versions

08/11 2015
12/07 2015
23/06 2015
14/06 2015
08/06 2015
01/06 2015
12/02 2015
13/01 2015
12/01 2015

dev-web-debugging

dev-web-debugging http://xp-framework.net/

Scriptlets for the XP Framework

  Sources   Download

BSD-3-Clause

The Requires

 

module xp

10/01 2015