chabiselx / debuggertools
Create a log for understand algorithm
Requires
- php: ^7 || ^8
Requires (Dev)
- doctrine/annotations: ^2.0
- doctrine/orm: ^2.19
- phpunit/phpunit: ^9.6
- symfony/cache: ^5.4
- dev-master
- 0.4.3
- 0.4.2
- 0.4.1.2
- 0.4.1.1
- 0.4.1
- 0.4.0
- 0.3.2
- 0.3.1.30
- 0.3.1.29
- 0.3.1.28
- 0.3.1.27
- 0.3.1.26
- 0.3.1.25
- 0.3.1.24
- 0.3.1.23
- 0.3.1.22
- 0.3.1.21
- 0.3.1.20
- 0.3.1.19
- 0.3.1.18
- 0.3.1.17
- 0.3.1.16
- 0.3.1.15
- 0.3.1.14
- 0.3.1.13
- 0.3.1.12
- 0.3.1.11
- 0.3.1.10
- 0.3.1.9
- 0.3.1.8
- 0.3.1.7
- 0.3.1.6
- 0.3.1.5
- 0.3.1.4
- 0.3.1.3
- 0.3.1.2
- 0.3.1.1
- 0.3.1.0
- 0.3.0.10
- 0.3.0.9
- 0.3.0.8
- 0.3.0.7
- 0.3.0.6
- 0.3.0.5
- 0.3.0.4
- 0.3.0.3
- 0.3.0.2
- 0.3.0.1
- 0.3.0.0
- 0.2.48
- 0.2.47
- 0.2.46
- 0.2.45
- 0.2.44
- 0.2.43
- 0.2.42
- 0.2.40
- 0.2.39
- 0.2.38
- 0.2.37
- 0.2.36
- 0.2.35
- 0.2.34
- 0.2.33
- 0.2.31
- 0.2.30
- 0.2.29
- 0.2.27
- 0.2.26
- 0.2.25
- 0.2.24
- 0.2.23
- 0.2.22
- 0.2.21
- 0.2.20
- 0.2.19
- 0.2.18
- 0.2.17
- 0.2.16
- 0.2.15
- 0.2.14
- 0.2.13
- 0.2.12
- 0.2.11
- 0.2.10
- 0.2.9
- 0.2.8
- 0.2.7
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2
- 0.1.1
- 0.1
- dev-test
This package is auto-updated.
Last update: 2025-06-04 08:27:22 UTC
README
Description
DebuggerTools is a toolkit for developers, designed to facilitate debugging of PHP applications. It offers a set of classes to capture and analyze various aspects of your code execution, including:
- Logger: To log messages, errors, and various information.
- Time Monitor: To measure and log the execution time of code segments.
- Memory Monitor: To measure memory consumption of code segments.
- Trace: To trace function calls and follow code execution with fine granularity.
Table of Contents
Installation
Install DebuggerTools using Composer:
composer require --dev chabiselx/debuggerTools
Or clone the repository directly:
git clone https://github.com/chaBiselx/DebuggerTools.git
cd DebuggerTools
composer install
Run Docker for Development
Create the .env.local
file at the project root.
Edit the ports in .env.local.env
according to other Docker images:
- PHP_EXT_PORT_1
- PHP_EXT_PORT_2
- BDD_EXT_PORT
Run Docker for the first time:
make docker-build
To debug the build if needed:
docker-compose build --no-cache 2>&1 | tee build_logs.txt
Access the PHP container:
docker exec -it debuggertools-php7_3-1 bash
Testing
Outside a container:
make docker-test
Inside a container:
To run all tests:
make test
To run a specific test:
make test FILTER=file::function
Usage
ArrayOfOption
The ArrayOfOption
parameter is an optional list. The possible fields are:
All:
hidePrefix
[boolean]: Hide the date at the beginning of the string (default: false)showPrefix
[boolean]: Show the date at the beginning of the string (default: true)purgeFileBefore
[boolean]: Purge the file before writing (default: false)expendObject
[boolean]: Expand for better visibility of arrays in the log file (default: false)fileName
[string]: Write to the file with the given name (default: log)
For the MemoryMonitor class:
activeConvertion
[boolean]: Enable unit-to-byte conversion (default: true)disactiveConvertion
[boolean]: Disable unit-to-byte conversion (default: false)
Logger
To capture logs in your application:
use DebuggerTools\Logger; $logger = new Logger($ArrayOfOption); $logger->logger($dataToLog);
Via singleton:
\Debuggertools\Logger::loggerStatic($dataToLog, $ArrayOfOption);
Time Monitor
To measure the execution time of a code section:
use DebuggerTools\TimeMonitor; $time = new TimeMonitor($ArrayOfOption); $time->set("label"); sleep(5); $time->log("label");
Memory Monitor
To monitor the memory used by your application:
use DebuggerTools\MemoryMonitor; $memoryMonitor = new MemoryMonitor($ArrayOfOption); $memoryMonitor->logMemoryUsage('label'); //function $memoryMonitor->logMemoryUsage('label');
Trace
To trace code execution:
use DebuggerTools\Trace; $trace = new Trace($ArrayOfOption); $trace->logTrace();
Via singleton:
\Debuggertools\Trace::getTraceStatic($ArrayOfOption);
Contribute
Contributions are welcome! If you want to contribute:
- Fork the repository.
- Create a branch for your changes (
git checkout -b feature/new-feature
). - Commit your changes (
git commit -m 'Add a new feature'
). - Push the branch (
git push origin feature/new-feature
). - Open a Pull Request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
TODO
- Improve the README
- Test Doctrine\ORM\PersistentCollection
- Middleware for all input/output
- EventListener for Symfony
- Fix SonarLint error (pathLog: getRootPath)