Download the PHP package padosoft/laravel-querymonitor without Composer

On this page you can find all versions of the php package padosoft/laravel-querymonitor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-querymonitor

Laravel QueryMonitor

Latest Version on Packagist CircleCI Quality Score Total Downloads

Laravel QueryMonitor is a package for Laravel that allows you to monitor and log:

Requirements

Installation

You can install the package via Composer:

Publish the configuration and migrations:

Configuration

The package configuration file is located at config/querymonitor.php. You can adjust the settings to suit your application's needs:

Usage

Once installed and configured, the package will automatically monitor and log SQL queries and Eloquent methods based on the provided settings. If you setting query total count to true, the package will automatically monitor and log total queries count.

Monitoring SQL Queries

Example Log Entry:

Monitoring Eloquent Methods

Example Log Entry:

Difference Between Monitoring SQL Queries and Eloquent Methods

SQL Queries

Eloquent Methods

Why Both?

Practical Example

Suppose we have the following code:

Analysis:

Monitoring the Total Number of Queries

In addition to monitoring slow queries and slow Eloquent methods, laravel-querymonitor allows you to track the total number of SQL queries executed during a single HTTP request, Artisan command, or CLI execution. This helps you identify cases where, although each individual query may be performant, the total number of queries is excessively high, potentially causing performance bottlenecks.

Why Monitor Total Queries? Even if every single query is fast, executing too many queries per request or command can cause unnecessary overhead. By monitoring the total query count, you can quickly identify scenarios where your application issues an excessive number of queries (for example, 2,000 queries in a single request), pinpointing areas that need optimization (e.g., using eager loading, caching, or refining data retrieval logic).

How It Works

Configuration

All configuration options are defined in the querymonitor.php config file under the total_queries key:

Enabling Total Query Monitoring for HTTP Requests

To track the total number of queries for HTTP requests, the package provides a TrackTotalQueriesMiddleware. This middleware must be added as the first middleware in the global middleware stack.

By doing so, it can:

How to add it:

In your app/Http/Kernel.php, ensure that \Padosoft\QueryMonitor\Middleware\TrackTotalQueriesMiddleware::class appears at the top of the $middleware array:

By placing the TrackTotalQueriesMiddleware first, you guarantee comprehensive coverage of every query executed during the request lifecycle. Once the request is fully processed, the middleware checks the total query count and logs a warning if it exceeds the configured threshold.

Examples of Logs

If a request executes more than the allowed number of queries, a log entry is created after the response is generated:

If an Artisan command triggers more queries than allowed, a warning is logged once the command finishes:

For CLI contexts (non-Artisan commands), if you set up tracking manually and the query count is exceeded, you'll see a log like:

Using the Regex Filter If you provide a traceRegEx:

For example, if you set:

only requests matching /api/... URLs are monitored.

Summary By configuring and enabling total query monitoring, you gain deeper insights into your application's performance, identifying excessive query usage patterns that can be addressed to improve overall efficiency. This is especially useful in complex, large-scale projects where minor optimizations in query counts can lead to significant performance gains.

Final Notes

Testing

The package includes unit tests to ensure all components function correctly. Run tests using PHPUnit:

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email instead of using the issue tracker.

Credits

About Padosoft

Padosoft (https://www.padosoft.com) is a software house based in Florence, Italy. Specialized in E-commerce and web sites.

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-querymonitor with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/support Version ^10.0|^11.0
illuminate/database Version ^10.0|^11.0
illuminate/log Version ^10.0|^11.0
illuminate/config Version ^10.0|^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package padosoft/laravel-querymonitor contains the following files

Loading the files please wait ....