jtrw/devutils

Libs for help to develop

1.2.4 2024-10-22 08:48 UTC

This package is auto-updated.

Last update: 2024-11-22 08:59:57 UTC


README

Install

composer require jtrw/devutils

Functions

dd(['test' => 1]);

Transliterate Convert cyr text to lat

$str = transliterate($str);

CliUtils

CliUtils::e('Some message'); // Output: [ERROR] Some message
CliUtils::i('Some message'); // Output: [INFO] Some message
CliUtils::s('Some message'); // Output: [OK] Some message
CliUtils::w('Some message'); // Output: [WARNING] Some message

You can choose some color for text:

CliUtils::color('Some text', 'red');

Supported Colors:

  1. black
  2. dark_gray
  3. blue
  4. light_blue
  5. green
  6. light_green
  7. cyan
  8. light_cyan
  9. red
  10. light_red
  11. purple
  12. light_purple
  13. brown
  14. yellow
  15. light_gray
  16. white

LoggerTrait

Use

class SomeClass
{
    use Jtrw\DevUtils\Logger\Traits\LoggerTrait;

    public function (LoggerInterface $logger)
    {
        $this->setLogger($logger)
    }

    public function doSome(array $params)
    {
        $this->i("Info for debug");
        $this->d("Debug something", $params);
        try {
            //Some logic
        } catch (Exception $exp) {
            $this->logException($exp, LOG_CRIT, "Exception happened");
        }
    }
}