21. 12. 2018 Gianluca Piccolo NetEye, Unified Monitoring

NetEye 4 PSR-7 implementation

When talking about data transmission the main thing to take care is that both
sides communicate in the same language.

The sender must be sure to send only stuff that the receiver can understand.

The receiver must know how to interpret the request and to process an
intelligible response for the sender.

Let me introduce you the Communication Protocols.

A Communication Protocol is a system of rules that allows two or more entities
in a communications system to transmit information via any kind of variation
of a physical quantity. The protocol defines the rules, syntax, semantics and
synchronization of communication as well as possible error recovery methods.

Therefore, a protocol definition is mandatory in order to establish
communication.

With the introduction in the Icinga Web 2 modules of the new IPL library
(Icinga PHP Library, more information can be found here),
new communication protocols have been defined to improve the way the data is
transferred from client to web server and viceversa.

The Icinga project has decided to base its entire communication activity on a
standard that has become very popular in the PHP world in recent years:
HTTP PSR-7.

PSR-7 defines the object structure of HTTP messages in PHP. Moreover, it
contains many functions that can access the HTTP data and manage it.

Basically PSR-7 is a set of rules that HTTP message objects must follow so
that everyone can implement the described behavior as desired. Fortunately,
there are many PHP open source libraries that implement this standard — you
don’t have to develop one on your own.

One such library is provided with the Guzzle package. Guzzle is an open source
HTTP client written in PHP which bases its client/server communication on the
PSR-7 standard, following its rules as optimally as possible.

We included that library in our custom Icinga Web 2 modules and we now
use its HTTP request/response objects to transfer information via HTTP in
NetEye.

In the future it will be included out-of-the-box in the IPL library, but for
now the only way is to deploy it separately.

The Guzzle PSR-7 implementation has very useful auto-create methods that
retrieve all the information from PHP superglobal variables, which is helpful for
those developers who want to use it. It automatically builds its objects
based on the context so they’re ready to be used.

The usage of standards like these will greatly improve the stability and
robustness of the NetEye 4 frontend, and will allow the development team to
be more flexible in satisfying customer requests both faster and with
higher quality.

Gianluca Piccolo
Full Stack Developer at Wuerth Phoenix. I love questioning myself, find new challenges to learn and new adventures to grow up. PHP lover trying to expand my skills studying new languages and tools to improve my professional life.

Author

Gianluca Piccolo

Full Stack Developer at Wuerth Phoenix. I love questioning myself, find new challenges to learn and new adventures to grow up. PHP lover trying to expand my skills studying new languages and tools to improve my professional life.

Leave a Reply

Your email address will not be published. Required fields are marked *

Archive