HTML Minifier PHP Example

Check the example on how to use
PHP
to minify a HTML hardcoded string and output to stdout:
<?php
    $url = 'https://www.toptal.com/developers/html-minifier/api/raw';

    // init the request, set various options, and send it
    $ch = curl_init();

    curl_setopt_array($ch, [
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => ["Content-Type: application/x-www-form-urlencoded"],
        CURLOPT_POSTFIELDS => http_build_query([ "input" => "<input type="text" />" ])
    ]);

    $minified = curl_exec($ch);

    // finally, close the request
    curl_close($ch);

    // output the $minified HTML
    echo $minified;
?>
Save the code to a file named
minify.php
and run the following command:
php minify.php

Output:

<input>