PHPackages                             alkemann/h2l - 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. [Framework](/categories/framework)
4. /
5. alkemann/h2l

ActiveLibrary[Framework](/categories/framework)

alkemann/h2l
============

A micro framework for websites and apis. This is a sequel of h.l, made for PHP 8

v0.64.0(3y ago)61.5k[2 PRs](https://github.com/alkemann/h2l/pulls)MITPHPPHP ^8.1CI passing

Since Mar 21Pushed 3mo ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (109)Used By (0)

H2L - microframework
====================

[](#h2l---microframework)

### Get started quickly with static pages and small apis

[](#get-started-quickly-with-static-pages-and-small-apis)

[![](https://github.com/alkemann/h2l/actions/workflows/tests.yml/badge.svg)](#)[![Packagist](https://camo.githubusercontent.com/e25562f743654efa776cf5e337593191361a2786/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616c6b656d616e6e2f68326c2e737667)](https://packagist.org/packages/alkemann/h2l)[![Tag](https://camo.githubusercontent.com/8c35ac99b3dab86eed3da6a0c175a1f1fb4e5d31/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f616c6b656d616e6e2f68326c2e737667)](https://github.com/alkemann/h2l/releases)[![PHP](https://camo.githubusercontent.com/fd2c9e029358801e37757426abee79c7d17ba0d53e612dbcb6f177ff2c95dbd6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50485025323076657273696f6e2d382e312d627269676874677265656e)](https://www.php.net/ChangeLog-8.php#PHP_8_1)[![codecov](https://camo.githubusercontent.com/84df9c42ce79c1b6ad80c3e6784dd08ecc7d814b/68747470733a2f2f636f6465636f762e696f2f67682f616c6b656d616e6e2f68326c2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/alkemann/h2l)[![StyleCI](https://camo.githubusercontent.com/06c5acdd9ceb6df2316e67bec61130f738e462ce/68747470733a2f2f7374796c6563692e696f2f7265706f732f35343432373335332f736869656c643f6272616e63683d6d6173746572267374796c653d666c6174)](https://styleci.io/repos/54427353)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/885f3cd511f91cff8d6b85f10a211d818054b3ee/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c6b656d616e6e2f68326c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alkemann/h2l/?branch=master)[![](https://camo.githubusercontent.com/b6d441ad4fe8332cb16c72aa27f22cc685181dfd74ae34964afc92c6c1146b3c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c2532306d61782d627269676874677265656e2e737667)](https://github.com/phpstan/phpstan)

Documentation
-------------

[](#documentation)

Hosted on Github pages:

Requirements
------------

[](#requirements)

- PHP 8.1

Install
-------

[](#install)

- Install via composer: `composer require alkemann/h2l`
- While you can use the library as only a lib, it comes with an index.php file. The library comes with 3 skeletons to get you started, the "min" contains basically just the index.php, the minimum expected folder structure and a hello world base route. You can also use the "base" that contains a an app, some base css, config files. Thirdly there is an "example" version that contains some more illustative example pages and dynamic routes. install by simply copying the skeleton folder contents of choice down to the root of your app (presumably the same folder that contains the "vendor" composer): `vendor/bin/skeleton base` (base automagic website using routes by files and folders). There more other skeleton alternatives:
    - `min` (bare bones)
    - `heroku_react` (set up for plug and play heroku app with H2L as backend and an react-redux frontend)
    - `heroku_min` (set up for plug and play heroku app with H2L)
    - `api` (no automagic routing, for pure api apps and specifically routed responses)
    - `hyper` (start out with Tailwind, alpine.js and HTMX for server side "SPA")

Usage from skeleton
-------------------

[](#usage-from-skeleton)

- Change the homepage by changing the file `content/pages/home.html.php`
- Add files and folders to `content/pages` to add fixed routed content
- Include a route file in `webroot/index.php` or add to `resources/configs/routes.php` if you installed the base skeleton.
- Add dynamic routes there by supplying a regex match on url and a closure handler:

Some example routes:

```
use alkemann\h2l\{Request, Router, Response, response\Json};

// Get task by id, i.e. GET http://example.com/api/tasks/12
Router::add(
  '|^api/tasks/(?\d+)$|',
  function(Request $request): Response
  {
    $id = $request->param('id'); // from the regex matched url part
    $data_model = app\Task::get($id);
    return new Json($data_model); // since Task model implements \JsonSerializable
  }
);

// http://example.com/version
Router::add('version', function($r) {
	return new Json(['version' => '1.3']);
});
```

Raw usage
---------

[](#raw-usage)

A minimal `webroot\index.php` could look something like this

```
$root_path = realpath(dirname(dirname(__FILE__)));
require_once($root_path . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');

use alkemann\h2l\{Environment, Dispatch};

Environment::setEnvironment(Environment::PROD);
Environment::set([
    'debug' => false,
    'layout_path'  => $root_path . 'layouts' . DIRECTORY_SEPARATOR,
    'content_path' => $root_path .  'pages' . DIRECTORY_SEPARATOR,
]);

$dispatch = new Dispatch($_REQUEST, $_SERVER, $_GET, $_POST);
$dispatch->setRouteFromRouter();
$response = $dispatch->response();
if ($response) echo $response->render();
```

Tests
-----

[](#tests)

To run tests you must can checkout the repo and require with dev and run `./bin/runtests` in the same folder as this README.md.

Or to run tests on the vendor included lib into your application, you must also require phpunit; `composer require phpunit/phpunit` and then you can run h2l tests with `vendor/bin/testh2l`

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance57

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity79

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~188 days

Total

105

Last Release

1385d ago

PHP version history (6 changes)0.1.0PHP ^7.0.0

v0.11.0PHP ^7.1.0

v0.48.0PHP ^7.3.0

v0.61.0PHP ^7.4

v0.62.0PHP ^8.0

v0.64.0PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![alkemann](https://avatars.githubusercontent.com/u/48854?v=4)](https://github.com/alkemann "alkemann (489 commits)")

---

Tags

composerdynamic-routesmicro-frameworkphpframeworkrouterroutingmicroframeworkphp8

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/alkemann-h2l/health.svg)

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

###  Alternatives

[vlucas/bulletphp

A heierarchical resource-oriented micro-framework built on nested closures instead of route-based callbacks

41949.9k1](/packages/vlucas-bulletphp)[pecee/simple-router

Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.

696214.6k17](/packages/pecee-simple-router)[developermarius/simple-router

Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.

112.4k](/packages/developermarius-simple-router)

PHPackages © 2026

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