Creating my first PHP Package

button99

Christos Koumpis

Posted on September 11, 2024

Creating my first PHP Package

Hello Devs,

I recently had the crazy idea of developing a PHP package for logging errors in scripts.

What inspired me?

As I started on building my very first package, the experience was nothing short of thrilling. The first question that I asked myself was "Why should I create this?" The answer soon followed.
I wanted a command-line tool that not only logs errors but does so in a vibrant, visually engaging way. With that in my mind, I opened my favorite code editor, turned to the PHP documentation, and began turning this idea into reality.

What does it do?

The package is simple and effective. It logs messages in PHP Scripts and presents them in a beautiful, colorful format, making debugging not only easier but also more enjoyable! You can check it out on Packagist ckoumpis/php-prompt

Code Samples

Here's a quick example of how you can use it:

Console::log("Hello from ckoumpis/php-prompt!");
Console::success("Operation successful!");
Console::error("An error occurred!");
Console::warning("Warning");Console::blue("This is a blue message");
Console::magenta("This is a magenta message");
Console::cyan("Cyan message for notification");
Enter fullscreen mode Exit fullscreen mode

Progress Bars and Spinners

The package also includes progress bars and spinners for better feedback in long running scripts:

for($i = 1; $i <= $total; $i++) {
    ProgressBar::display($i, $total);
    usleep(10000);
}
Enter fullscreen mode Exit fullscreen mode

Or with steps

ProgressBar::withSteps(1, 10, 1);
Enter fullscreen mode Exit fullscreen mode

For Spinners

for($i = 0; $i < 10; $i++) {
    Spinner::spin();
    sleep(1);
}
Enter fullscreen mode Exit fullscreen mode

Or with Steps

Spinner::withSteps(0, 10, 1);
Enter fullscreen mode Exit fullscreen mode

Collaboration

I welcome anyone to contribute in the project. I would love for others to join me in making this tool even better. Together we can build something cool and useful.

💖 💪 🙅 🚩
button99
Christos Koumpis

Posted on September 11, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Creating my first PHP Package
php Creating my first PHP Package

September 11, 2024