2017 © Pedro Peláez
 

library h2l

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

image

alkemann/h2l

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

  • Tuesday, July 24, 2018
  • by alkemann
  • Repository
  • 1 Watchers
  • 3 Stars
  • 356 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 51 Versions
  • 1 % Grown

The README.md

H2L - microframework

Get started quickly with static pages and small apis

Packagist Tag PHP codecov StyleCI Scrutinizer Code Quality , (*1)

Documentation

Hosted on Github pages: https://alkemann.github.io/h2l/, (*2)

Requirements

  • PHP 8.1

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

  • 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:, (*3)

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/(?<id>\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

A minimal webroot\index.php could look something like this, (*4)

$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

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., (*5)

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, (*6)

The Versions

24/07 2018

dev-master

9999999-dev https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

06/12 2017

v0.37.0

0.37.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

27/11 2017

v0.36.0

0.36.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

18/09 2017

v0.35.0

0.35.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

14/09 2017

v0.34.0

0.34.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

14/09 2017

v0.33.1

0.33.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

07/09 2017

v0.33.0

0.33.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

01/09 2017

v0.32.2

0.32.2.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

30/08 2017

v0.31.2

0.31.2.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

27/08 2017

v0.31.1

0.31.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

26/08 2017

v0.31.0

0.31.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

26/08 2017

v0.30.0

0.30.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

18/08 2017

v0.29.0

0.29.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

15/08 2017

v0.28.3

0.28.3.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

15/08 2017

v0.28.2

0.28.2.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

15/08 2017

v0.28.1

0.28.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

15/08 2017

v0.28.0

0.28.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

14/08 2017

v0.27.2

0.27.2.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

14/08 2017

v0.27.1

0.27.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

13/08 2017

v0.27.0

0.27.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

13/08 2017

v0.26.1

0.26.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

13/08 2017

v0.26.0

0.26.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

09/08 2017

v0.25.1

0.25.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

09/08 2017

v0.25.0

0.25.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

07/08 2017

v0.24.0

0.24.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

07/08 2017

v0.23.0

0.23.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

05/08 2017

v0.22.1

0.22.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

05/08 2017

v0.22.0

0.22.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

02/08 2017

v0.21.0

0.21.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

02/08 2017

v0.20.2

0.20.2.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

02/08 2017

v0.20.1

0.20.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

02/08 2017

v0.20.0

0.20.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

02/08 2017

v0.19.1

0.19.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

01/08 2017

v0.19.0

0.19.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

01/08 2017

v0.18.1

0.18.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

01/08 2017

v0.18.0

0.18.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

30/07 2017

v0.17.1

0.17.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

30/07 2017

v0.17.0

0.17.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

22/07 2017

v0.16.3

0.16.3.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

22/07 2017

v0.16.2

0.16.2.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

22/07 2017

v0.16.1

0.16.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

22/07 2017

v0.16.0

0.16.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

20/07 2017

v0.15.0

0.15.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

20/07 2017

v0.13.1

0.13.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

19/07 2017

v0.13.0

0.13.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

14/07 2017

v0.12.0

0.12.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

22/03 2017

v0.11.1

0.11.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

16/03 2017

dev-dev

dev-dev https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

22/02 2017

v0.11.0

0.11.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.1.0

 

The Development Requires

framework routing php7 microframework router

21/02 2017

v0.10.0

0.10.0.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.0.0

 

The Development Requires

framework routing php7 microframework router

30/03 2016

v0.9.1

0.9.1.0 https://github.com/alkemann/h2l

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

  Sources   Download

MIT

The Requires

  • php ^7.0.0

 

The Development Requires

framework routing php7 microframework router