Download the PHP package spatie/flare-client-php without Composer

On this page you can find all versions of the php package spatie/flare-client-php. 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 flare-client-php

Send PHP errors to Flare

Latest Version on Packagist Run tests PHPStan Total Downloads

This repository contains the PHP client to send errors and exceptions to Flare. The client can be installed using composer and works for PHP 8.0 and above.

Using Laravel? You probably want to use Ignition for Laravel. It comes with a beautiful error page and has the Flare client built in.

Screenshot of error in Flare

Documentation

When creating a new project on Flare, we'll display installation instructions for your PHP app. Even though the default settings will work fine for all projects, we offer some customization options that you might like.

Ignoring errors

The Flare client will always send all exceptions to Flare, you can change this behaviour by filtering the exceptions with a callable:

Additionally, you can provide a callable to the Flare::filterReportsUsing method to stop a report from being sent to Flare. Compared to filterExceptionsCallable, this can also prevent logs and errors from being sent.

Finally, it is also possible to set the levels of errors reported to Flare as such:

Controlling collected data

Just like the Laravel configuration, the generic PHP client allows you to configure which information should be sent to Flare.

Anonymizing IPs

By default, the Flare client collects information about the IP address of your application users. If you want to disable this information, you can call the anonymizeIp() method on your Flare client instance.

Censoring request body fields

When an exception occurs in a web request, the Flare client will pass on any request fields that are present in the body.

In some cases, such as a login page, these request fields may contain a password that you don't want to send to Flare.

To censor out values of certain fields, you can use call censorRequestBodyFields. You should pass it the names of the fields you wish to censor.

This will replace the value of any sent fields named "password" with the value "".

Identifying users

When reporting an error to Flare, you can tell the Flare client, what information you have about the currently authenticated user. You can do this by providing a user group that holds all the information you want to share.

Linking to errors

When an error occurs in web request, your application will likely display a minimal error page when it's in production.

If a user sees this page and wants to report this error to you, the user usually only reports the URL and the time the error was seen.

To let your users pinpoint the exact error they saw, you can display the UUID of the error sent to Flare.

You can do this by displaying the UUID returned by Flare::sentReports()->latestUuid() in your view. Optionally, you can use Flare::sentReports()->latestUrl() to get a link to the error in Flare. That link isn't publicly accessible, it is only visible to Flare users that have access to the project on Flare.

In certain cases, multiple error can be reported to Flare in a single request. To get a hold of the UUIDs of all sent errors, you can call Flare::sentReports()->uuids(). You can get links to all sent errors with Flare::sentReports()->urls().

It is possible to search for certain errors in Flare using the UUID, you can find more information about that here.

Adding custom context

When you send an error to Flare within a non-Laravel application, we do not collect your application information - since we don't know about your specific application. In order to provide more information, you can add custom context to your application that will be sent along with every exception that happens in your application. This can be very useful if you want to provide key-value related information that furthermore helps you to debug a possible exception.

The Flare client allows you to set custom context items like this:

This could for example be set automatically in a Laravel service provider or an event. So the next time an exception happens, this value will be sent along to Flare and you can find it on the "Context" tab.

Grouping multiple context items

Sometimes you may want to group your context items by a key that you provide to have an easier visual differentiation when you look at your custom context items.

The Flare client allows you to also provide your own custom context groups like this:

Adding glows

In addition to custom context items, you can also add "Glows" to your application. Glows allow you to add little pieces of information, that can later be found in a chronological order in the "Debug" tab of your application.

You can think of glows as breadcrumbs that can help you track down which parts of your code an exception went through.

The Flare PHP client allows you to add a glows to your application like this:

Stacktrace arguments

When an error occurs in your application, Flare will send the stacktrace of the error to Flare. This stacktrace contains the file and line number where the error occurred and the argument values passed to the function or method that caused the error.

These argument values have been significantly reduced to make them easier to read and reduce the amount of data sent to Flare, which means that the arguments are not always complete. To see the full arguments, you can always use a glow to send the whole parameter to Flare.

For example, let's say you have the following Carbon object:

Flare will automatically reduce this to the following:

It is possible to configure how these arguments are reduced. You can even implement your own reducers!

By default, the following reducers are used:

Implementing your reducer

Each reducer implements Spatie\FlareClient\Arguments\Reducers\ArgumentReducer. This interface contains a single method, execute which provides the original argument value:

In the end, three types of values can be returned:

When the reducer could not reduce this type of argument value:

When the reducer could reduce the argument value, but a part was truncated due to the size:

When the reducer could reduce the full argument value:

For example, the DateTimeArgumentReducer from the example above looks like this:

Configuring the reducers

Reducers can be added as such:

Reducers are executed from top to bottom. The first reducer which doesn't return an UnReducedArgument will be used. Always add the default reducers when you want to define your own reducer. Otherwise, a very rudimentary reduced argument value will be used.

Disabling stack frame arguments

If you don't want to send any arguments to Flare, you can turn off this behavior as such:

Missing arguments?

Handling exceptions

When an exception is thrown in an application, the application stops executing and the exception is reported to Flare. However, there are cases where you might want to handle the exception so that the application can continue running. And the user isn't presented with an error message.

In such cases it might still be useful to report the exception to Flare, so you'll have a correct overview of what's going on within your application. We call such exceptions "handled exceptions".

When you've caught an exception in PHP it can still be reported to Flare:

In Flare, we'll show that the exception was handled, it is possible to filter these exceptions. You'll find more about filtering exceptions here.

Writing custom middleware

Before Flare receives the data that was collected from your local exception, we give you the ability to call custom middleware methods. These methods retrieve the report that should be sent to Flare and allow you to add custom information to that report.

Just like with the Flare client itself, you can add custom context information to your report as well. This allows you to structure your code so that you have all context related changes in one place.

You can register a custom middleware by using the registerMiddleware method on the Spatie\FlareClient\Flare class, like this:

To create a middleware that, for example, removes all the session data before your report gets sent to Flare, the middleware implementation might look like this:

Identifying users

When reporting an error to Flare, you can tell the Flare client, what information you have about the currently authenticated user. You can do this by providing a user group that holds all the information you want to share.

Customizing error grouping

Flare has a special grouping algorithm that groups similar error occurrences into errors to make understanding what's going on in your application easier.

While the default grouping algorithm works for 99% of the cases, there are some cases where you might want to customize the grouping.

This can be done on an exception class base, you can tell Flare to group all exceptions of a specific class together:

In this case every exception of the SomeExceptionClass will be grouped together no matter what the message or stack trace is.

It is also possible to group exceptions of the same class together, but also take the message into account:

Be careful when grouping by class and message, since every occurrence might have a slightly different message, this could lead to a lot of different errors.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Testing

Contributing

Please see CONTRIBUTING for details.

Security

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

License

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


All versions of flare-client-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/pipeline Version ^8.0|^9.0|^10.0|^11.0|^12.0
spatie/backtrace Version ^1.6.1
symfony/http-foundation Version ^5.2|^6.0|^7.0
symfony/mime Version ^5.2|^6.0|^7.0
symfony/process Version ^5.2|^6.0|^7.0
symfony/var-dumper Version ^5.2|^6.0|^7.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 spatie/flare-client-php contains the following files

Loading the files please wait ....