PHPackages                             groundwork/groundwork-hacklang - 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. [API Development](/categories/api)
4. /
5. groundwork/groundwork-hacklang

ActiveLibrary[API Development](/categories/api)

groundwork/groundwork-hacklang
==============================

A Hack framework for making RESTful JSON APIs

0.1.0(11y ago)16221MITPHP

Since Jul 11Pushed 11y ago2 watchersCompare

[ Source](https://github.com/ndavison/groundwork-hacklang)[ Packagist](https://packagist.org/packages/groundwork/groundwork-hacklang)[ RSS](/packages/groundwork-groundwork-hacklang/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

groundwork-hacklang - A micro-framework for RESTful JSON API development
========================================================================

[](#groundwork-hacklang---a-micro-framework-for-restful-json-api-development)

[![Build Status](https://camo.githubusercontent.com/5e88cc2a9121d62cd0958d02c4bacdceb67e64709e8febc6f4c7d77dfe76a1e4/68747470733a2f2f7472617669732d63692e6f72672f6e64617669736f6e2f67726f756e64776f726b2d6861636b6c616e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ndavison/groundwork-hacklang)

written in (mostly) strict Hack.

This is a rewrite of [groundwork](https://github.com/ndavison/groundwork), from PHP to mostly strict [Hack](http://hacklang.org) - "mostly" because there is currently no way to bootstrap Hack code in strict mode (since it doesn't allow top level code), and also due to some reliance on the $\_SERVER super global.

groundwork is a lightweight RESTful-like framework that is designed to accept input and output in JSON. It is designed to quickly get a backend communicating with a backbone.js, or equivalent, frontend.

groundwork-hacklang offers the following features:
--------------------------------------------------

[](#groundwork-hacklang-offers-the-following-features)

- Assign routes to a closure.
- Routes support parameters you can label and retrieve by name.
- Stateless i.e. no $\_SESSION, $\_COOKIE references in the core.
- JSON input decoding and output encoding (just as backbone.js expects).
- Easily respond to requests using common HTTP status codes.
- Simple handling of GET, POST, PUT and DELETE HTTP methods on resources.
- A footprint of about 20KB at the core.

Examples
--------

[](#examples)

In the following example, I'll setup a quick route to respond to the request `/articles/199`. In app/Config/Routes.php, add:

```
$router->register('articles/:id', function($ioc) {
    $request = $ioc->get('request');
	$response = $ioc->get('response');
	if ($request instanceof Request && $response instanceof Response) {
		$response->send(200, $request->routeParams);
	} else {
		throw new ServerException('IoC failed to resolve.');
	}
});
```

This will respond with `{"id":"199"}` in the response body when handed the request `/articles/199`, and a HTTP status code of 200. This is not HTTP request method specific.

To make a route respond to specific HTTP request methods, you can replace register() with get(), post(), put() or delete(). E.g.:

```
$router->post('articles/:id', function($ioc) {
    $request = $ioc->get('request');
	$response = $ioc->get('response');
	if ($request instanceof Request && $response instanceof Response) {
		$response->send(200, $request->routeParams);
	} else {
		throw new ServerException('IoC failed to resolve.');
	}
});
```

This would respond to `/articles/199` only when the request is a HTTP POST.

Installation
------------

[](#installation)

- Requires [HHVM](http://hhvm.com). Tested on 3.0.1.
- Requires [Composer](http://getcomposer.org)

groundwork is designed to have the 'public' directory as the only directory in the package accessible externally. This means that if you're installing groundwork under a VirtualHost in Apache, the web root should point to the 'public' directory (e.g. /var/www/groundwork/public, perhaps). If you're installing groundwork under a sub directory of web root and not as its own virtual host, then you can setup an Apache alias to the public directory to achieve a nicer directory on the web side.

The file app/Config/Config.php contains the `baseurl` property which you will need to change to reflect where groundwork exists relative to the web root - e.g. if it is installed into , then '/bar/' would be your value for this.

Run `composer update` from the project root. Groundwork has no inbuilt requirments as far as packages go, but does make use of the Composer class autoloading.

Tests
-----

[](#tests)

A basic function test is provided inside app/Tests for the example home resource class. There are also unit tests available in framework/Tests. To run the tests, I've found this command works (from the root groundwork dir):

`hhvm $(which phpunit)`

License
-------

[](#license)

groundwork-hacklang is open-sourced software licensed under the MIT License.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4329d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3828f44e787c43da833d6f4f76391b1be7eb836a2c2c37289579371c39dcf789?d=identicon)[ndavison](/maintainers/ndavison)

---

Top Contributors

[![ndavison](https://avatars.githubusercontent.com/u/1152676?v=4)](https://github.com/ndavison "ndavison (6 commits)")[![weinliu](https://avatars.githubusercontent.com/u/36030569?v=4)](https://github.com/weinliu "weinliu (1 commits)")

---

Tags

jsonapihhvmrestfulhackbackbone.js

### Embed Badge

![Health badge](/badges/groundwork-groundwork-hacklang/health.svg)

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

###  Alternatives

[obiefy/api-response

Simple Laravel package to return Json responses.

17324.6k](/packages/obiefy-api-response)[walle89/swedbank-json

Unofficial API client for the Swedbank's and Sparbanken's mobile apps in Sweden.

752.5k](/packages/walle89-swedbank-json)[wayofdev/laravel-symfony-serializer

📦 Laravel wrapper around Symfony Serializer.

2113.6k](/packages/wayofdev-laravel-symfony-serializer)

PHPackages © 2026

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