Laminas / Text / Figlet

Hello Forum,

I’m terribly new to web development, and I’m attempting to use the Laminas/Text/Figlet library to render figlet in php on my website. I have a shared hosting plan which features php 8.x, apache, and shell access to composer, I was able to install the Laminas/Text/Figlet/Figlet() library via composer, and linked the autoload.php to my html thusly:

        require __DIR__ . '/vendor/autoload.php';
        use Laminas\Text\Figlet;
        $figlet = new Laminas\Text\Figlet\Figlet();
         echo $figlet->render('test');

I was finally able to get it to work, but when it’s rendered on the webpage instead of looking like a chubby block of text like figlet normally does, it appears that the figlet is just parsed on one whole line with no carriage returns. Here is “test” rendered on the webpage:

Or this, the image above isn’t displaying properly, so I’ve pasted the figlet which has been rendered below, it’s working but it’s not arranging the ascii characters to build the figlet font properly:

______ _____ _____ ______ /_ _// | ___|| / ___// /_ _// `-| |,- | ||__ \___ \\ `-| |,- | || | ||__ / // | || |_|| |_____|| /____// |_|| `-`' `-----` `-----` `-`'

Are there any secrets to getting the text to render with extra parameters? I’ve tried scouring the web for extra information and trying to tinker with the different options hasn’t yielded any results.

Any help would be appreciated, thank you!

Hello and welcome to your forums! :smiley:

The rendering is correct because HTML needs an explicit line break via the br element to create a new line in the browser output. If you want to display the text on your website, then you can use the pre element or use CSS with the white-space property and pre-line value.

But for a presentation on a website, an image is better suited than these text characters.

Hello froschdesign,

Thank you for your help, I was able to wrap the function in a <div> and applied some CSS to finally get it to render properly.

And yes, I’m figuring out due to scaling that it looks like it’s much easier to create an image rather than hope all of those scaling stars align!

Thank you!