Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaxwilko/profiler
PHP profiler powered by XDebug
https://github.com/jaxwilko/profiler
Last synced: about 1 month ago
JSON representation
PHP profiler powered by XDebug
- Host: GitHub
- URL: https://github.com/jaxwilko/profiler
- Owner: jaxwilko
- License: mit
- Created: 2021-06-22T13:13:02.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-04-14T02:33:29.000Z (over 2 years ago)
- Last Synced: 2024-10-12T13:10:56.687Z (3 months ago)
- Language: PHP
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# jaxwilko/profiler
This package aids development by allowing you to profile sections of your codebase.
## Installation
```shell
composer require "jaxwilko/profiler" --dev
```## Usage
Firstly, you need to [install ext-xdebug](https://xdebug.org/docs/install).
Then add the following to your `php.ini`:
```ini
[xdebug]
xdebug.mode = develop,gcstats,profile,trace
xdebug.collect_return = 1
xdebug.collect_assignments = 1
xdebug.use_compression = false
```Once this has been done, you can add the following to your codebase:
```php
use JaxWilko\Profiler\Watcher;Watcher::start();
// execute application logic
Watcher::end(__DIR__ . '/output.html');
```
The filename passed will be used to store the resulting parsed profile. Alternatively you can call `end()`
without any params to get the profile as a variable.
```php
$profile = Watcher::end();
```
The watcher also supports returning the profile as an array, this can be done as follows:
```php
Watcher::setMode(Watcher::OUTPUT_ARR);
$profile = Watcher::end();
```
There are helpers provided to achieve the same functionality:
```php
jax_watcher_start();
// execute application logic
jax_watcher_end($outputFile);
```