Skip to content

Commit c8ab85d

Browse files
authored
Merge pull request #45 from buggregator/issue/39
Adds an example on how to send xhprof trace from vanilla php
2 parents 7bd4272 + c23e33e commit c8ab85d

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

docs/config/var-dumper.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ $_SERVER['VAR_DUMPER_FORMAT'] = 'server';
4242
$_SERVER['VAR_DUMPER_SERVER'] = '127.0.0.1:9912';
4343
```
4444

45+
You can also set these variables using a bash script.
46+
47+
```bash
48+
#!/bin/bash
49+
50+
export VAR_DUMPER_FORMAT="server"
51+
export VAR_DUMPER_SERVER="127.0.0.1:9912"
52+
```
53+
4554
That's it! Now you can use the `dump()` and `dd()` functions as usual. The output will be sent to the remote server.
4655

4756
## Browser performance

docs/config/xhprof.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,55 @@ composer require --dev maantje/xhprof-buggregator-laravel
6565
> **Note:**
6666
> Read more about package usage in the [package documentation](https://github.com/maantje/xhprof-buggregator-laravel).
6767
68+
## Vanilla PHP
69+
70+
If you are using Vanilla PHP you just need to install
71+
the [spiral-packages/profiler](https://github.com/spiral-packages/profiler) package.
72+
73+
```bash
74+
composer require --dev spiral-packages/profiler
75+
```
76+
77+
And then configure a `WebStorage` client from the package to send data to Buggregator.
78+
79+
Here is an example:
80+
81+
```php
82+
use SpiralPackages\Profiler\Profiler;
83+
use SpiralPackages\Profiler\Driver\DriverInterface;
84+
use SpiralPackages\Profiler\DriverFactory;
85+
use SpiralPackages\Profiler\Storage\StorageInterface;
86+
use SpiralPackages\Profiler\Storage\WebStorage;
87+
use Symfony\Component\HttpClient\NativeHttpClient;
88+
89+
$storage = new WebStorage(
90+
new NativeHttpClient(),
91+
'http://127.0.0.1/api/profiler/store',
92+
);
93+
94+
$driver = DriverFactory::detect();
95+
96+
$profiler = new Profiler(
97+
storage: $storage,
98+
driver: $driver,
99+
appName: 'My super app',
100+
tags: [
101+
// global tags
102+
'env' => 'local',
103+
]
104+
);
105+
106+
$profiler->start(ignoredFunctions: []);
107+
108+
// Here is your code you want to profile
109+
110+
$profiler->end(tags: [
111+
// Tags for specific requests
112+
]);
113+
```
114+
115+
Where `http://127.0.0.1/api/profiler/store` is the endpoint to send data to Buggregator.
116+
68117
## Configuration
69118

70119
After installing the package, you need to configure it. The package provides predefined environment variables to

0 commit comments

Comments
 (0)