ollily/ezlogging

Simplify the usage of - Logging with Monolog - Testing with PHPUnit - Reflection with PHP - Developer shortkeys for composer

Installs: 26

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

pkg:composer/ollily/ezlogging

0.6.1 2025-08-21 14:42 UTC

This package is auto-updated.

Last update: 2025-10-06 11:02:57 UTC


README

ezlogging?&logo=github&style=plastic&sort=semver ezlogging?&logo=github&style=plastic ezlogging?&logo=github&style=plastic ezlogging?&logo=github&style=plastic ezlogging?&logo=github&style=plastic

phpunit UNIT Tests violet?&style=plastic&logo=php sonarcloud oGlow way violet?&style=plastic&logo=sonar codacy oGlow Rulset violet?&style=plastic&logo=codacy coveralls Coverage violet?&style=plastic&logo=coveralls

php cs fixer PSR2 & PSR12 violet?&style=plastic&logo=php phpstan Level 8 Strict violet?&style=plastic&logo=php psalm Level 2 violet?&style=plastic&logo=php php codesniffer PSR2 & PSR12 violet?&style=plastic&logo=php php mess detector codesize & cleancode & controversial & design & naming & unusedcode violet?&style=plastic&logo=php

Table of Contents

Description

Simplify the usage of

  • Logging with Monolog

  • Testing with PHPUnit

  • Reflection with PHP

  • Developer shortkeys for composer

Usage

Monolog

PHPUnit

Reflection

Examples

PHPUnit

Business Class
<?php

declare(strict_types=1);

namespace foo;

class FooClazz
{
    public function isValid(): bool
    {
        return true; // not very complex, i know ;-)
    }
}
Related test class
<?php

declare(strict_types=1);

namespace foo;

require_once __DIR__ . './bootstrap.php';

use PHPUnit\Framework\EasyGoingTestCase;

class FooClazzTest extends EasyGoingTestCase
{
    protected function prepareO2t(): FooClazz // cast to business class
    {
        return new FooClazz();
    }

    protected function getCasto2t(): FooClazz // cast to business class
    {
        return $this->o2t;
    }

    public function testFoo(): void
    {
        $this->logger->debug('testFoo() - Start');

        // test code
        static::assertTrue($this->getCasto2t()->isValid());
        // or
        static::assertTrue($this->o2t->isValid());

        $this->logger->info('testFoo() - End');
    }
}
Log output
PHPUnit 9.6.25 by Sebastian Bergmann and contributors.

20250821-162846.609 [DEBUG   ] PHPUnit\Framework\EasyGoingTestCase->testFoo() - testFoo() - Start
20250821-162846.611 [INFO    ] PHPUnit\Framework\EasyGoingTestCase->testFoo() - testFoo() - End
..

Reflection

Extended class example
<?php

declare(strict_types=1);

namespace foo;

class FooClazz
{
    private $privateFoo = 'privateFooValue';

    protected function protectedFoo(): string
    {
        return 'protectedFooMethod';
    }
}
Related extended test class example
<?php

declare(strict_types=1);

namespace foo;

require_once __DIR__ . './bootstrap.php';

use ollily\Tools\Reflection\UnavailableFieldsTrait;
use ollily\Tools\Reflection\UnavailableMethodsTrait;
use PHPUnit\Framework\EasyGoingTestCase;

class FooClazzTest extends EasyGoingTestCase
{
    use UnavailableFieldsTrait;
    use UnavailableMethodsTrait;

    protected function prepareO2t(): FooClazz // cast to business class
    {
        return new FooClazz();
    }

    protected function getCasto2t(): FooClazz // cast to business class
    {
        return $this->o2t;
    }

    public function testPrivateField(): void
    {
        $result = $this->getFieldFromO2t('privateFoo');
        // or
        $result2 = $this->getFieldByReflection(FooClazz::class, 'privateFoo', $this->o2t);
        $this->logger->info("privateFoo is '${result}' or '${result2}'");

        static::assertEquals('privateFooValue', $result);
        static::assertEquals($result, $result2);
    }

    public function testProtectedMethod(): void
    {
        $result = $this->callMethodOnO2t('protectedFoo');
        // or
        $result2 = $this->callMethodByReflection(FooClazz::class, 'protectedFoo', $this->o2t);
        $this->logger->info("protectedFoo returns '${result}' or '${result2}'");

        static::assertEquals('protectedFooMethod', $result);
        static::assertEquals($result, $result2);
    }
}
Log output
PHPUnit 9.6.25 by Sebastian Bergmann and contributors.

20250821-162846.588 [INFO    ] PHPUnit\Framework\EasyGoingTestCase->testPrivateField() - privateFoo is 'privateFooValue' or 'privateFooValue'
20250821-162846.608 [INFO    ] PHPUnit\Framework\EasyGoingTestCase->testProtectedMethod() - protectedFoo returns 'protectedFooMethod' or 'protectedFooMethod'
..

Additional Information

Notice

sonarcloud light

Reference

(c) 2025 by Oliver Glowa