Installation

The Table Generator is available via Composer, making installation and updates straightforward. Follow the steps below to install and set up the library in your project.

1. Install via Composer

Run the following command to install Table Generator:

composer require ucscode/table-generator

This will download and install the package along with its dependencies.

2. Requirements

Ensure your environment meets the following requirements:

  • PHP 8.2 or higher
  • Composer installed

3. Autoloading

If your project does not use a framework that automatically loads dependencies, include Composer’s autoloader manually:

require 'vendor/autoload.php';

This ensures all Table Generator classes are available for use.

4. Basic Usage Example

Once installed, you can start using Table Generator immediately. Below is a simple example that converts MySQL query results into an HTML table:

use Ucscode\HtmlComponent\TableGenerator\TableGenerator;
use Ucscode\HtmlComponent\TableGenerator\Adapter\MysqliResultAdapter;

$mysqli = new mysqli("localhost", "username", "password", "database");
$result = $mysqli->query("SELECT * FROM users");

$adapter = new MysqliResultAdapter($result);
$table = new TableGenerator($adapter);

echo $table->render();

5. Updating Table Generator

To update to the latest version, run:

composer update ucscode/table-generator

This ensures you always have the latest features and bug fixes.

Source Code
If you find this project useful, consider leaving a on GitHub! Thank you!