How do I configure buggregator for a vanilla PHP app? #206
-
The documentation is quite sparse on information on how one would go about configuring xhprof and vardumper if you're just running a vanilla PHP application. The "configuration" sections probably only apply to the packages for Laravel and Spiral, unless I'm mistaken. A what levels of the stack would I need to integrate these systems and how would one go about it? I can't find much good documentation on xhprof |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hey! To configure var dumper for a vanilla PHP application, you just need to use Here's a quick example: // Plain PHP
$_SERVER['VAR_DUMPER_FORMAT'] = 'server';
$_SERVER['VAR_DUMPER_SERVER'] = '127.0.0.1:9912'; You can also set these variables using a bash script. #!/bin/bash
# Set environment variables for var dumper
export VAR_DUMPER_FORMAT="server"
export VAR_DUMPER_SERVER="127.0.0.1:9912" For xhprof, it's a good idea to add a setup section for vanilla PHP applications. Thanks for the suggestion! It's not too hard. Just use the Here's an example: use SpiralPackages\Profiler\Profiler;
use SpiralPackages\Profiler\Driver\DriverInterface;
use SpiralPackages\Profiler\DriverFactory;
use SpiralPackages\Profiler\Storage\StorageInterface;
use SpiralPackages\Profiler\Storage\WebStorage;
use Symfony\Component\HttpClient\NativeHttpClient;
$storage = new WebStorage(
new NativeHttpClient(),
'http://127.0.0.1/api/profiler/store',
);
$driver = DriverFactory::detect();
$profiler = new Profiler(
storage: $storage,
driver: $driver,
appName: 'My super app',
tags: [
// global tags
'env' => 'local'
]
);
$profiler->start(ignoredFunctions: []);
// Here is your code you want to profile
$profiler->end(tags: [
// Tags for specific requests
]); Hope this helps! If you need more details, let me know! It would be awesome if you could create a PR to the docs repository to improve the documentation for vanilla PHP users. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
Hey! To configure var dumper for a vanilla PHP application, you just need to use
$_SERVER
variables. Check this out: Var Dumper Configuration.Here's a quick example:
You can also set these variables using a bash script.
For xhprof, it's a good idea to add a setup section for vanilla PHP applications. Thanks for the suggestion! It's not too hard. Just use the
spiral-packages/profiler
composer package.Here's an example: