Skip to content
Sahil-Gulati edited this page Aug 25, 2017 · 7 revisions

Introduction

This library has been implemented to separate PHP from HTML to avoid a messy structure and code. Usually it can be fine and understandable to have very few lines of code of PHP in your HTML template but what gonna happen if you whole page or HTML template if full of If-else , foreach , while or switch so there PHPHump will come into play where you can define cleaner HTML content without have to create a messy stuff. This whole framework on some predefined attributes, tags and templating engine usage formats, and Yes this is the key-factor to learn this library.

As Usual, there is nothing which can be started without a Hello World!

Getting started

Hello World

Hello world

1. Create a simple hello world template with name default.hump.php

<html>
    <head>
        <title>My first hump page</title>
    </head>
    <body>
        <div>
            Hello world!
        </div>
    </body>
</html>

2. Create a file with name default.php

<?php

define('HUMP_DIR','/path/to/hump/template/folder/');
/**
 * Load dependencies via autoloader
 */
require_once 'vendor/autoload.php';
/**
 * Create class object and path to hump template file
 */
$humpObject= new  PHPHump\Hump(HUMP_DIR."default.hump.php");
/**
 * Most importantly you should execute and echo out the content
 * generated via Hump templateing engine
 */
echo $humpObject->execute();

Note:

1. Specified filenames are just examples, you can pick anyone.

2. Once you execute this default.php on your browser you template will be visible.

Clone this wiki locally