Download the PHP package debughub/php-client without Composer
On this page you can find all versions of the php package debughub/php-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-client
DebugHub.com PHP client
Debughub helps your development process by logging all requests to your application and showing them in debughub.com application. It helps you find issues in your code faster and find performance issues while still in developemnt.
Installation:
This package is for plain PHP. For Laravel installation go to debughubs laravel repo
-
add the package to composer.json in
require
section"debughub/php-client": "0.1.*"
-
create new config file in config dir with content:
- Somewhere in your code init the debughub client:
$debughub = new \Debughub\Clients\Php\Debughub('path/to/config');
Be sure to import the composer's autoload as well. From now on debughub client will send request and response info to debughub.com
Available extra methods
You can use these methods to add extra information about your application. You can log queries and logs using debughub. All your request and response information will be sent automatically.
DB Queries
To log query use the $debughub->query(string $query, array $data, string $duration, string $connection)
method.
For example if you use a class for all your Database querying, you can simply add this method to the method, that calls the query. Or you can just add it after the query you want to log.
$query
- query to execute. You can add a ?
instead of any query params, you want to replace in the query. For example SELECT * FROM Users where id = ?;
and send the user's ID in data variable.
$data
- array of data, that should replace the ?
in your code. This will not be send if you disable send_query_data
in the config.
$duration
- seconds it took to execute the query.
$connection
- name of the DB connection. Usefull if your application uses multiple connections
Example:
Or you can have debughub calculate the duration as well like this:
Logging
To add a simple log use $debughub->log(string $data, string $type)
method
Logs work just like queries. You can use log() method to log just one action for example.
$data
- data to log. It can be any data type, arrays and objects will be serialized.
$type
('info' by default) - Name of the log. This will change the way log shows up in the debughub.com application. It should be info
, error
or warning
.
By default the log does not have a duration and in debughub's timeline will show up just as a small line. If you want to measure duration of something, for example API call to external API, you can use:
Routes
If you want to add route to your log, you can do it using $debughub->route(string $route)
method.
For example: