IceHawk installation

This documentation shows you how to basically install the IceHawk component.

Interactive installer

We provide an interactive installer package, that can be issued using composer's create project command.

Assuming you already have downloaded the composer.phar, simply run:

php composer.phar create-project icehawk/installer /path/to/new-project

The installer will ask you some basic questions about your namings to set up your new project and lets you optionally choose to install further IceHawk components.

Watch our short video and see how it works: Install IceHawk framework in less than 2 minutes

The installation results in a minimal, ready-to-use web application project setup with one read (GET) and one write (POST) route.

You can help us improve the interactive installer.

Please note: For reasons of automation the installer initially installs some thrid-party dependencies. These will be removed at the end of the installation process.

Manual installation

Step 1 - require icehawk/icehawk

If you already have created a composer.json for your project, then just add the dependency by running:

php composer.phar require icehawk/icehawk:^2.0

or adding it manually:

    "require": {
        "icehawk/icehawk": "^2.0"

— composer.json

and running:

php composer.phar update

Step 2 - Create a request handler

Assuming your project namespace is YourVendor\YourProject.

<?php declare(strict_types = 1);

namespace YourVendor\YourProject;

use IceHawk\IceHawk\Interfaces\HandlesGetRequest;
use IceHawk\IceHawk\Interfaces\ProvidesReadRequestData;

final class SayHelloRequestHandler implements HandlesGetRequest
    public function handle( ProvidesReadRequestData $request ) 
        echo "Hello World!";   

— SayHelloRequestHandler.php

Step 3 - Create a basic config

All you need is at least one read or write route.

<?php declare(strict_types = 1);

namespace YourVendor\YourProject;

use IceHawk\IceHawk\Routing\ReadRoute;
use IceHawk\IceHawk\Routing\Patterns\Literal;
use YourVendor\YourProject\SayHelloRequestHandler;

final class IceHawkConfig extends \IceHawk\IceHawk\Defaults\IceHawkConfig
    public function getReadRoutes() 
        return [
            new ReadRoute( new Literal('/'), new SayHelloRequestHandler() ),    

— IceHawkConfig.php

Step 4 - Create a bootstrap script

<?php declare(strict_types = 1);

namespace YourVendor\YourProject;

use IceHawk\IceHawk\IceHawk;
use IceHawk\IceHawk\Defaults\IceHawkDelegate;


$iceHawk = new IceHawk(new IceHawkConfig(), new IceHawkDelegate());


— index.php

Webserver config

IceHawk is designed to have a bootstrap script (index.php) that receives all requests. So you should configure your webserver to pass all requests to that script. Here is how this is usually done:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /index.php [L,QSA]

— Apache (.htaccess)

location / {
    try_files $uri $uri/ /index.php?$args;

— nginx

Now you can visit http://your.domain/ and should see Hello World!.

That's it.