DEV Community

Cover image for Mezon Html Report generator
alexdodonov
alexdodonov

Posted on • Edited on

2 1

Mezon Html Report generator

Hi! Let me introduce eport generator wich I have created for personal use.

To be honest I don't like create reports. It took soooooooo mcuh time. But this class now allows me to do it much faster.

Pros and cons

Mezon HTML report generator allows you to create reports in a simple and pretty way. This tool also shortens time wich you spend on coding.

This package is a part of Mezon Framework

Installation

Just type:

composer require mezon/html-report
Enter fullscreen mode Exit fullscreen mode

Usage

Lets start from creating object of the report generator:

$report = new Html();
Enter fullscreen mode Exit fullscreen mode

And since that moment we can add elements to the head or body:

// not that stylesheets are not validated, it is totally on your side
$report->head()->style()->selector('p')->css('color', 'red');
$report->head()->style()->selector('div')->css('color', 'green');;

$report->body()->p('Hello!');
$report->body()->div('World!');

// here we get HTML code in the variable $result
$result = $report->compile();
Enter fullscreen mode Exit fullscreen mode

More complex examples

This example shows that every call creates new tag (except html and body). So if you want to add multyple tags then you need to store tag into variable:

$table = $report->table();
$row = $table->tr();

$row->td()->innerHtml('#1');
$row->td()->innerHtml('Legolas');

$row->td()->innerHtml('#2');
$row->td()->innerHtml('Frodo');

$row->td()->innerHtml('#3');
$row->td()->innerHtml('Aragorn');
Enter fullscreen mode Exit fullscreen mode

Supported tags

For now you can use following tags:

  • body
  • div
  • h1
  • h2
  • h3
  • h4
  • h5
  • head
  • p
  • strong
  • style
  • table
  • td
  • tr

Inner HTML

If you need more tags, you can use innerHtml like in the example below:

$report->body()->innerHtml('<script>alert(1);</scrip>');
Enter fullscreen mode Exit fullscreen mode

Learn more

More information can be found here:

Twitter
Mezon Framework

It will be great if you will contribute something to this project. Documentation, sharing the project in your social media, bug fixing, refactoring, or even submitting issue with question or feature request. Thanks anyway )

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay