"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Creating my first PHP Package

Creating my first PHP Package

Published on 2024-11-04
Browse:412

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");

Progress Bars and Spinners

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

for($i = 1; $i 



Or with steps

ProgressBar::withSteps(1, 10, 1);

For Spinners

for($i = 0; $i 



Or with Steps

Spinner::withSteps(0, 10, 1);

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.

Release Statement This article is reproduced at: https://dev.to/button99/creating-my-first-php-package-1j52?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3