Download the PHP package vinewu/php-profiler without Composer
On this page you can find all versions of the php package vinewu/php-profiler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-profiler
PHP Profiler
A PHP profiling library to submit profilings to XHGui.
Supported profilers:
- Tideways XHProf v5.x: PHP >= 7.0
- XHProf: PHP >= 5.3, PHP >= 7.0
- Tideways v4.x: PHP >= 7.0
- UProfiler: PHP >= 5.3, < PHP 7.0
This profiling library will auto-detect any supported profiler and use that.
The specific profiler can be chosen by profiler
config key.
Goals
- Compatibility with PHP >= 5.3.0
- No dependencies aside from the relevant extensions
- Customizable and configurable so you can build your own logic on top of it
Usage
In order to profile your application, you need to:
- Install this package
- Install profiler extension
- Instantiate the profiler
- Configure saver to send data to XHGui
- Import jsonl files (optional)
Installation
The supported way to install this package is via composer:
Create profiler
Creating profiler would be something like this:
If you need to disable profiler doing flush
, session_write_close
and
fastcgi_finish_request
at the end of profiling, pass false
to register
shutdown handler:
Using config file
You can create config/config.php
and load config from there:
- copy
config/config.default.php
toconfig/config.php
- use
Config::create()
tonew Profiler
Advanced Usage
You might want to control capture and sending yourself, perhaps modify data before sending.
Autoloader
To be able to profile autoloader, this project provides autoload.php
that
loads classes needed to start up the profiler.
Load it before loading composer autoloader:
Loading composer autoloader is still needed when saving results to MongoDB or PDO directly.
Config
Reference config of what can be configured:
- examples/autoload.php
It includes all configuration options and inline documentation about the options.
Savers
To deliver captured data to XHGui, you will need one of the savers to submit to the datastore XHGui uses.
- Stack saver
- Upload saver
- File saver
- MongoDB Saver (deprecated)
- PDO Saver (deprecated)
- Custom Saver Custom saver
Stack saver
Allows saving to multiple handlers.
The example config configures to use Upload Saver, and if that fails, save to File Saver:
Upload saver
This is the recommended saver as it's the easiest to set up.
Example config:
File saver
If your site cannot directly connect to your XHGui instance, you can choose to save your data to a temporary file for a later import to XHGui.
Example config:
To import a saved files, see Import jsonl files section.
MongoDB Saver
NOTE: Saving directly to MongoDB is discouraged, use Upload/File/Stack saver instead.
For saving directly to MongoDB you would need ext-mongo for PHP 5
and ext-mongodb with alcaeus/mongo-php-adapter package for PHP 7
along with perftools/xhgui-collector
package:
for PHP 5:
for PHP 7:
Example config:
PDO Saver
NOTE: Saving directly to PDO is discouraged, use Upload/File/Stack saver instead.
PDO Saver should be able to save to any PDO driver connection.
You will need to install additionally perftools/xhgui-collector
package:
Example config:
Custom Saver
You can create your own profile saver by implementing SaverInterface
and calling setSaver()
.
Import jsonl files
You can use ./bin/import.php
script to submit files saved by File Saver to XHGui server.
- Setup config file
- Configure to use Upload Saver
- Execute the
./bin/import.php
script
The script can take multiple jsonl formatted files, or if none given read stdin stream.
Configure Profiling Rate
You may want to change how frequently you profile the application. The
profiler.enable
configuration option allows you to provide a callback
function that specifies the requests that are profiled.
The following example configures to profile 1 in 100 requests, excluding
requests with the /blog
URL path:
In contrast, the following example instructs to profile every request:
Profile using XHProf helper
If you want to start profiling using a browser based tool like XHProf helper, You can use this method:
Configure 'Simple' URLs Creation
This library generates 'simple' URLs for each profile collected. These URLs are
used to generate the aggregate data used on the URL view. Since different
applications have different requirements for how URLs map to logical blocks of
code, the profile.simple_url
configuration option allows you to provide
the logic used to generate the simple URL.
By default, all numeric values in the query string are removed.
Configure ignored functions
You can use the profiler.options
configuration value to set additional options
for the profiler extension. This is useful when you want to exclude specific
functions from your profiler data:
In addition, if you do not want to profile all PHP built-in functions,
Add ProfilingFlags::NO_BUILTINS
, to 'profiler.flags'.
Installing profilers
For this library to capture profiling data, you would need any of the profiler extension. Depending on your environment (PHP version), you may need to install different extension.
Supported profilers:
- Tideways XHProf v5.x: PHP >= 7.0
- XHProf: PHP >= 5.3, PHP >= 7.0
- Tideways v4.x: PHP >= 7.0
- UProfiler: PHP >= 5.3, < PHP 7.0
Tideways XHProf (5.+)
Tideways XHProf v5.x requires PHP >= 7.0.
To install tideways_xhprof
extension, see their installation documentation.
Alternatively on brew
(macOS) you can use packages from kabel/pecl tap:
For outdated php versions few recipes exist in glensc/tap tap:
XHProf
XHProf supports all PHP versions.
xhprof
0.9.x requires PHP >= 5.3, < PHP 7.0xhprof
2.x requires PHP >= 7.0
for PHP 5.x:
for PHP >=7.0:
Alternatively on brew
(macOS) you can use packages from kabel/pecl tap:
Tideways (4.x)
Tideways 4.x extension requires with PHP >= 7.0.
To install tideways
extension, see their installation documentation.
UProfiler
UProfiler requires PHP >= 5.3, < PHP 7.0
To install uprofiler
extension, see their installation documentation.
All versions of php-profiler with dependencies
ext-json Version *