Skip to content

Hello World!

John Aldrich Bernardo edited this page Feb 12, 2018 · 2 revisions

index.php

Make sure to have your copy of calf.

<?php

require("vendor/autoload.php");

$app = new \Calf\App();

$home = new \Calf\HTTP\Route('/', function($req, $res) {
        return $res->write('Hello World!');
    });

$app->add($home);

$app->run();

.htaccess

In order to work, Calf is using Web Servers URL rewriting engine so you'll need to configure one.

Don't know how to configure one? Click .htaccess.

Here is a basic sample configuration:

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

Up and Running

Test your Hello World application using PHPs built-in Web Server.

php -S localhost:8888 index.php

Visit localhost:8888 in your favorite browser and see your application Up and Running.

Clone this wiki locally