PHPackages                             quazardous/rlw - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. quazardous/rlw

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

quazardous/rlw
==============

16182PHP

Since Oct 22Pushed 10y ago1 watchersCompare

[ Source](https://github.com/quazardous/rlw)[ Packagist](https://packagist.org/packages/quazardous/rlw)[ RSS](/packages/quazardous-rlw/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

RLW
===

[](#rlw)

Rest Like Webservice bootstrap

Goal
====

[](#goal)

Provide a lightweight bootstrap/framework for REST like webservice/JSON API.

REST like philosophy
====================

[](#rest-like-philosophy)

Say you want to handle blog Posts.

You'll have to provide a getPost() request and a putPost() request. And maybe you'll have a addComment() request. But at the end those three requests will probably return the Post object...

With RLW you can define a main post() request and add subrequests : put() and addComment().

RLW manages (sub)requests dependencies. So if a Post does not exist subrequests will be cancelled.

One of the side effects is to save some HTTP calls : you can "package" many actions in one request.

Bootsrap
========

[](#bootsrap)

The ./foo folder shows a basic webservice (used with PHPUnit tests).

Webservice class
----------------

[](#webservice-class)

The core is the Foo\\Webservice\\WebserviceFoo class. It provides the (sub)request/class map.

```
protected $_requestHandlersClassMap = array(
  'foo/#main' => "RequestHandler\\RequestHandlerFooDefault",
  'foo/bar'   => "RequestHandler\\RequestHandlerFooDefault",
  'foo/foo'   => "RequestHandler\\RequestHandlerFooDefault",
  'foo/boo'   => "RequestHandler\\RequestHandlerFooDefault",
  'foo/far'   => "RequestHandler\\RequestHandlerFooDefault",
);

```

Request class
-------------

[](#request-class)

You must implement at least the execute() method wich must return TRUE if successfull. Mainly you will do your stuff an set status and data to return.

- setStatus(): define the ststus (default 200/success)
- setResponseData(): specify some data to return
- canAccess(): you can tell RLW if this request can be executed
- isValid(): you can tell RLW if request is correct
- alterRequests(): you can alter all (sub)requests...

Data Validation
---------------

[](#data-validation)

You can describe the input data and RLW takes care of the data validation.

```
protected $_requestParameterDefinitions = array(
  'freeStringsArray' => array(
     'type' => 'array',
     'nested' => 'string',),
  'sizeStringsArray' => array(
      'type' => 'array',
      'min' => 3,
      'max' => 10,
      'nested' => 'string',),
  );

```

Type definition
---------------

[](#type-definition)

You can define a custom user type.

```
protected $_typeDefinitions = array(
  'my_struct' => array(
    'type' => 'struct',
    'struct' => array(
      'foo' => array('type' => 'string'),
      ),
  ),
);

```

And use it.

```
 protected $_requestParameterDefinitions = array(
  'field' => array(
     'type' => '',
     'mandatory' => true,),
 );

```

PHP SDK
=======

[](#php-sdk)

RLW comes with a basic PHP SDK.

Basic request:

```
require_once "rlw/sdk/php/src/RLW.php";
$ws = new RLW('http://mysite.com/my/api');
$request = $ws->createRequest('foo');
$request->r = rand();
$res = $request->execute();
...

```

With a subrequest:

```
require_once "rlw/sdk/php/src/RLW.php";
$ws = new RLW('http://mysite.com/my/api');
$request = $ws->createRequest('foo');
$request->r = rand();
$bar = $request->subRequest('bar');
$bar->x = 'something';
$res = $request->execute();
...

```

see rlw/sdk/php/tests/FooTest.php for more examples.

Syntax
======

[](#syntax)

Here is the raw HTTP syntax.

Request
-------

[](#request)

Request can be GET params (for simple one) or POST JSON.

In example:

GET request: /api/foo/?bar=1

is equivalent to

POST request: /api/foo/

sending:

```
{
  #request: {bar: 1}
}

```

If API call has both GET and POST/JSON, API will merge request but POST will take over GET.

Subrequest
----------

[](#subrequest)

POST API calls can have “sub” requests:

```
{
  #request: {bar: 1},
  mySubRequestTag: {
    #name: 'mySubRequest',
    ...
  }
}

```

You can ommit the #name:

```
{
  #request: {bar: 1},
  mySubRequest: {...}
}

```

Equivalent to:

```
{
  #request: {bar: 1},
  mySubRequest: {
    #name: 'mySubRequest',
    ...
  }
}

```

response to sub requests are sent like:

```
{
  #status: ,
  #data: ,
  mySubRequestTag: ,
}

```

status for sub request and request are not linked.

Response
--------

[](#response)

Response is in JSON.

```
{
  #status: {
    code: ,
    message: ,
    [details: [ [optional] : [list of] sub request tag to be successful

```

You can refer to the main request with a '#main' tag. You ca put the #requires in the main request. The API will perform a topoligical sort to determine the right order of execution.

Example:

```
{
  #request: {bar: 1},
  #requires : "myOtherSubRequest",
  myFirstSubRequest: {...}
  myOtherSubRequest: {"#requires": "myFirstSubRequest", ...},
}

```

Exceptions
----------

[](#exceptions)

API can raise an exception if something goes wrong. The exception replaces the normal response.

Example:

```
{
  "#exception": {
    type: "Exception",
    code: 0,
    message: "Something is wrong"
  }
}

```

Folders
=======

[](#folders)

- foo: dummy webservice for example
- sdk: PHP basic SDK

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f9b424f56493e5f1fa6ae1edf6552cefbb24755fd9949618e57c9373edcd8ce6?d=identicon)[quazardous](/maintainers/quazardous)

---

Top Contributors

[![quazardous](https://avatars.githubusercontent.com/u/1506211?v=4)](https://github.com/quazardous "quazardous (48 commits)")

### Embed Badge

![Health badge](/badges/quazardous-rlw/health.svg)

```
[![Health](https://phpackages.com/badges/quazardous-rlw/health.svg)](https://phpackages.com/packages/quazardous-rlw)
```

###  Alternatives

[tpoxa/shortcodes

Wordpress style shorttags support for Yii2

2213.9k](/packages/tpoxa-shortcodes)[hashandsalt/kirby-chopper

Kirby 3 Chopper plugin for truncating text

251.4k](/packages/hashandsalt-kirby-chopper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
