PHPackages                             jchook/house - 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. jchook/house

ActiveLibrary

jchook/house
============

House PHP — A minimal MVC Application Toolset

2151PHP

Since Oct 21Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jchook/house)[ Packagist](https://packagist.org/packages/jchook/house)[ RSS](/packages/jchook-house/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

House
=====

[](#house)

A super-minimal pure PHP MVC toolkit.

Controller
----------

[](#controller)

The controller layer is the interface for your application. Use it to define a `Route`, accept a `Request`, and return a `Response`.

### Hello World

[](#hello-world)

We'll start with a Hello world route in `app.php`.

```
$app = new House\Router;
$app->get('/', function($req, $resp){
	return 'Hello World';
});
```

### Advanced route matching

[](#advanced-route-matching)

The router is powerful in its simplicity.

- Exact string match
- Regular expressions
- Simplified expressions
- Arbitrary callbacks
- An array of the above

Try this simplified expression route that says hello to an arbitrary name.

```
$app->get('/hello/:name', function($req){
	return 'Hello ' . $req->param('name');
});
```

You can even nest routes based on criteria:

```
$app->group('/user', function($app){
	$app->put(function(){
		// Create user
	})
	->get('/:id', function(){
		// Retrieve user
	})
	->post('/:id', function(){
		// Update user
	})
	->delete('/:id', function(){
		// Delete user
	});
});
```

You can attach middleware to routes with `before()` and `after()`.

```
$app->before('*', function($req, $resp){
	House\Log::info('Request: ' . $req);
	$resp->code(200);
});
```

You can optionally catch errors per route as well.

```
$app->error('*', function($req, $resp){
	House\Log::error($req->exception->getMessage());
	return 500;
});
```

Notice that controller return values are passed to `$response->write()`.

- Strings write to the repsonse body
- Integers set the response code
- Arrays for Rack-style response

See `example.php` for more examples of exactly how badass `Router` is.

Model
-----

[](#model)

The model layer is very basic. There is no ORM. If you need a more robust model layer, please see Symfony or php-activerecord. Otherwise, check this:

```
class User extends House\Model {}

// throws House\NotFound
User::find(['id' => 1]);

// returns array()
$users = User::where(['status' => ['active', 'inactive']])->limit(5)->all();
```

### Supported databases

[](#supported-databases)

- MySQL
- More to come..

View
----

[](#view)

The view layer is almost vanishingly small. It's so simple, it doesn't even need to exist. Returning a string from a controller method automatically calls `$response->write($string)`.

So, view helpers are any method that return a string. We've bundled a few to get you started, but House could potentially support any template engine, flat file, etc. Since House is not a framework, there is no special View registry or folder, so you can easily install alternative template engines with composer and use them as-is.

Quickly configure your app to use Haml for example:

```
House\Haml::config([
	'cache' => sys_get_temp_dir() . '/haml',
	'views' => __DIR__ . '/views',
]);

function haml($view, $vars = array(), $config = array()) {
	return new House\Haml($view, $vars, $config);
}
```

Then implement it in your application with ease:

```
$app->get('/', function($req){
	return haml('index', $req->params());
});
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

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/047da3410a118e06b8f9e170318c1c1197a6dbd5ceebe1a43ee91251d49c7632?d=identicon)[jchook](/maintainers/jchook)

---

Top Contributors

[![groovenectar](https://avatars.githubusercontent.com/u/595446?v=4)](https://github.com/groovenectar "groovenectar (3 commits)")

### Embed Badge

![Health badge](/badges/jchook-house/health.svg)

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

PHPackages © 2026

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