We are witnessing a deep transformation within the NetEye 4 core: Icinga Web 2 will move from the Zend Framework to a totally new library called IPL (Icinga PHP Library). This change is already underway in the NetEye 4.3 release with the new version of the Director module. The Icinga team has already partially introduced the IPL library in Director and started using this new framework without completely removing Zend.
The IPL is intended to be a challenging, robust PHP framework. This PHP library provides a layer of abstraction allowing you to easily create database connections, forms and other HTML elements. For now the IPL project is a work in progress, and additional exciting features will be integrated and shipped with the Icinga Web 2.5 release.
The project at the moment is composed of an SQL part and the HTML one. IPL\SQL provides a database connection abstraction and an SQL-query layer for building SQL queries via an OOP API.
For example you can easily set up a database connection using the Connection
class, just by passing an array containing the configuration parameters:
new Connection([ 'db' => 'mysql', 'host' => '192.0.2.42', 'port' => '3306', 'dbname' => 'customers', 'username' => 'dbAdmin', 'password' => '123456', 'charset' => 'utf8', 'attributes' => [] //optional ])
The SQL package also provides useful classes for the Select
, Insert
, Update
and Delete
queries. For example, to run a query you just need to set up a database connection as described before and then simply call the appropriate function:
// Example for an insert query $this->dbConnection->insert($table, $values); // Example for an update query $this->dbConnection->update($table, $values, $where);
IPL\HTML instead provides a structure that guarantees that every time you require an implementation of the ipl\Html\ValidHtml
interface, you won’t have to worry about escaping HTML content at all. With the Html
class you can create each HTML tag. For example you can create an h1
tag as follows:
Html::tag('h1', 'Hello world!');
There are two methods you can use to include the result. First, you can use these classes directly in your .phtml file. Second, you can create a generic $content
variable, add all your HTML elements to it and then just print $content
to the .phtml file.
$content = Html::tag('div'); $content->add(Html::tag('h1', 'Hello world!')); Html::tag('h1', 'Hello world!');
In your index.phtml
you should put:
<?php echo $content ?>
and you will get
<div><h1>Hello world!</h1></div>
We have started developing new modules based on IPL and will certainly contribute to this project in the future in order to increase the number of features provided. The first module that will be released based completely on IPL, removing any dependency with Zend Framework, will be our new IcingaWeb2 module Geomap. We are pleased that after some initial difficulties due to a steep learning curve for IPL, we now see an improvement in NetEye 4 development. This new framework is much more intuitive and flexible then Zend: it allows you to easily create new custom elements, extend existing classes and guarantees support for some of the most frequently used Zend functions.