Download the PHP package soyhuce/dev-tools without Composer
On this page you can find all versions of the php package soyhuce/dev-tools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package dev-tools
Dev Tools
Tools for Laravel development
- Installation
- Available tools
- Debug
- Bottleneck Middleware
- Image Faker
Installation
You can install the package via composer:
Laravel will discover the service provider Soyhuce\DevTools\ServiceProvider
.
After installing Dev Tools, publish its assets using:
You can also add the facade to your alias in config\app.php
:
Available tools
- Debug : Debugging tools
- Artisan
- Counter
- Database
- Memory
- Message
- Model
- Request
- Response
- Time
- Special case of http testing
- BottleneckMiddleware : Middleware simulating a bottleneck
- Image faker : Generates random images locally
Debug
When activated, it allows logging some information on request execution: HTTP request, HTTP response, database requests, timings or even used memory.
All collected information timestamped and sent in your default log channel, with debug level.
Every module can be activated or deactivated separately thanks to the config file. You can configure the timestamp format as you wish.
Artisan
Information are collected when running artisan commands. Artisan collector will collect the command name, argument and options when collection comes from an artisan command.
Counter
The counter can help to count stuffs. The counter does not need to exist before incrementing it. As it is initialized with 0.
Counters can be incremented by more than one.
Database
Every executed database query is collected with its bindings and duration. The total number of executed queries is also logged.
You can define a threshold and raise a warning if the number of executed queries is above this threshold.
Memory
The Memory collector will collect the memory peak usage and add it to the log.
You can define a threshold and raise a warning if the memory peak usage id above this threshold.
Message
You can send messages in the debugger flow calling Debug::message
Model
When enabled, the collector allows you to count the number of models retrieved from the database during the queries.
Request
Request data can be collected. We store HTTP verb, url and parameters.
Response
Response can also be collecter with its status code and body.
Time
Time collector will automatically measure booting time (laravel) and application time (your application).
It is possible to time performance portions via the facade :
startMeasure
and stopMeasure
calls do not have to be in the part of code, but a measure cannot be stopped if not started (nor started if already running).
Above example can be simplified using Debug::measuring
method :
All running measurements are stopped before logging.
You can also measure multiple times with the same key. All measures are stored together, and the log will provide you some statistics.
Finally, you can define a threshold and raise a warning if the application duration is above this threshold.
Special use case of HTTP testing
When doing http testing, it is common to bootstrap database or execute some operation we do not want to add to our debug log.
For example:
We are actually not interested in (for example) database queries of factory(\App\User::class)->create()
nor assertDatabaseHas
.
This package will take care of drop any collected information during bootstrap and return only interesting ones i.e. what occurred in $this->putJson("api/users/{$user->id}",['name' => 'John Doe'])
.
You just have to ensure that you are using testing
environment during your tests (which should already be your case as it is Laravel default).
BottleneckMiddleware
This middleware adds some latency to your requests, server side. It can be useful to check how your application behaves when the user does not have a good network connection.
Soyhuce\DevTools\Middlewares\BottleneckMiddleware
can be used as a classic middleware.
To use it, just add the middleware in your App/Http/Kernel.php
or in your route file(s).
You can modify bottleneck duration in config/dev-tools.php
file.
You also may want to apply it for only ajax requests. If so, adjust the only_ajax
value. Please ensure that the ajax requests are sent with the X-Requested-With
header set to XMLHttpRequest
.
Image Faker
Sometimes you want to generate images locally for testing, placeholders, ...
You can then use Soyhuce\DevTools\Faker\Image
to do so. For this, you have to install intervention/image
.
It will generate an image with random color and with the given text (or "width x height"). For example :
Image::generate(200, 150)
Image::generate(300, 100, 'The colors are not that good', 'png')
See intervention/image documentation to know how to use returned image.
All versions of dev-tools with dependencies
illuminate/http Version ^10.15 || ^11.0
illuminate/support Version ^10.15 || ^11.0