HTML (Qiq)

Setup

Install bear/qiq-module in composer to get HTML view in Qiq.

composer require bear/qiq-module

Next, Provide a directory to store templates and helpers.

cd /path/to/project
cp -r vendor/bear/qiq-module/var/qiq var

Provide the html context file src/Module/HtmlModule.php and install QiqModule.

namespace MyVendor\MyPackage\Module;

use BEAR\Package\AbstractAppModule;
use BEAR\QiqModule\QiqModule;


class HtmlModule extends AbstractAppModule
{
    protected function configure()
    {
        $this->install(new QiqModule($this->appMeta->appDir . '/var/qiq/template'));
    }
}```

## Change context

Change the context of `bin/page.php` to enable `html`.

```bash
$context = 'cli-html-app';

Template

Prepare the template for the Index resource in var/qiq/template/Page/Index.php.

<h1>{{h $this->greeting }}</h1>

The $body of the ResourceObject will be assigned to the template as $this.

php bin/page.php get /
200 OK
content-type: text/html; charset=utf-8

<h1>Hello BEAR.Sunday</h1>

Custom helper

Custom Helpers will be created in the Qiq\Helper\ namespace. Example: Qiq\Helper\Foo.

Specify the Qiq\Helper in the autoload of composer.json (e.g: composer.json) and run composr dump-autoload to enable to autoload the custom helper class. Custom helpers placed in the specified directory will be made available.

ProdModule

Install a module in ProdModule to make the error page HTML for production and to enable compiler cache.

class ProdModule extends AbstractModule
{
    protected function configure()
    {
        $this->install(new QiqErrorModule);
        $this->install(new QiqProdModule($this->appDir . '/var/tmp');
    }
}