Support the ongoing development of Laravel.io →
Article Hero Image

🍃 Termwind v1.0 Released!

6 Dec, 2021 2 min read

Photo by Joan Gamell on Unsplash

Termwind Released!

Termwind allows you to build unique and beautiful PHP command-line applications, using the Tailwind CSS API with an HTML Renderer. In short, it's like Tailwind CSS, but for the PHP command-line applications.

Termwind was created by Francisco Madeira and Nuno Maduro, and after almost three months of development Termwind v1.0 is available, and you can start using on your projects.

Checkout the repository on GitHub!

Why?

One of many things that annoyed all the CLI developers was to add some margin before the content, just to have some breathing room, without Termwind the only way was to add spaces before each line, now with Termwind you can just pass the class ml-2 and you will have two spaces on every line for that element, just like how we do for the browser.

This example shows how easy it is to create a beautiful CLI output, with simple knowledge of HTML and TailwindCSS.

Termwind Released!

use function Termwind/render;

render(<<<HTML
    <div class="m-1">
        <div class="w-full text-center bg-green-400 text-black">
            <b>Termwind</b> v1.0 Released!
        </div>
        <p class="w-full text-center">
            After almost three months of development <b>Termwind</b> v1.0 is live.
        </p>
    </div>
HTML);

Now, lets create an output just like PEST

For this example we will take advantage of the Laravel Framework Command with a blade view.

PEST Example

TermwindReleasedCommand.php

<?php

namespace App\\Console\\Commands;

use Illuminate\\Console\\Command;
use function Termwind\\render;

class TermwindReleasedCommand extends Command
{
    protected $signature = 'termwind:released';

    public function handle()
    {
        return render(view('termwind', [
            'files' => [[
                'name' => 'Tests\\TermwindReleasedTest',
                'tests' => [[
                    'name' => 'it is ready to use!',
                ]],
            ]],
            'totalTests' => 1,
            'totalTime' => '0.20s',
        ]));
    }
}

termwind.blade.php

<div class="mx-2 my-1">
    @foreach ($files as $file)
        <div>
            <span class="px-1 font-bold bg-green text-black">PASS</span>
            {{ $file['name'] }}
        </div>
        @foreach ($file['tests'] as $test)
            <div class="text-gray-400">
                <b class="text-green">✓</b> {{ $test['name'] }}
            </div>
        @endforeach
    @endforeach

    <div class="mt-1">
        <span class="w-8">Tests:</span>
        <b class="text-green">{{ $totalTests }} passed</b>
    </div>

    <div>
        <span class="w-8">Time:</span>
        <span>{{ $totalTime }}</span>
    </div>
</div>

What's next? As v1.0 is ready to use on production. The future developments we will focus on improving our documentation and provide a lot more use case examples.

Get involved! This is a community project and we are always looking for people to contribute.

As a joke I added to my Twitter Description "I built everything with HTML and CSS" and all of a sudden I start working on Termwind and the API is based around HTML and CSS classes. ?

Last updated 3 weeks ago.
0
Like this article? Let the author know and give them a clap!

Other articles you might like

Article Hero Image November 18th 2024

Laravel Custom Query Builders Over Scopes

Hello 👋 Alright, let's talk about Query Scopes. They're awesome, they make queries much easier to r...

Read article
Article Hero Image November 19th 2024

Access Laravel before and after running Pest tests

How to access the Laravel ecosystem by simulating the beforeAll and afterAll methods in a Pest test....

Read article
Article Hero Image November 11th 2024

🍣 Sushi — Your Eloquent model driver for other data sources

In Laravel projects, we usually store data in databases, create tables, and run migrations. But not...

Read article

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.