Understanding Ignition – Laravel’s new bug report (part 2)

Tram Ho

Introduce

  • Continuing Part 1, Part 2 is about learning more about Ignition – Laravel 6.x’s new bug report
  • See the original article link here
  • See the content of part 1 in the series.

content

Ignition tabs

Request tab

request-tab

Next to the “Stack trace” tab, is the Request tab. It displays all the information of a request.

App tab

app-tab

App tab will display some pretty interesting information. It displays the information about your application. They will first show which route the exception is taking place, it will include controllers that execute if it is available, and the name of its route. Another great feature is its ability to display route parameters in your request.

Let’s come up with an example, to better understand. We have a route defined as follows:

If an exception appears on this route, we will display the components of the post model after converting it to an array type via the toArray () function. As well as the simple route parameters that will be displayed before the bindings, so we have an accurate view of what information Laravel has received as part of that route. After the route param, we will display the middleware information, which is used with the above request. Next we have the VIEW section, if the exception occurs in a certain view, we will display the name of the view, and also display all data thrown into the view.

❓ I don’t know if there is a tool to manage the versions of Laravel, for example, I can use Laravel 5.5 and Laravel 5.6 in parallel on the same device. There must be some solution, right?

User Tab

user-tab

The tab contains information about who is using the app, and what browser they use.

Context tab

context-tab

In the context tab, will show your repo git information (including repo location, hash commit code) and environment information (such as php version and Laravel version) that you use.

Debug tab

debug-tab

In the Debug tab, we will display information where the exception occurred, everything like queries, logs, and dump will be displayed. Next, when displaying a dump, we will display the filename where you left the dump command. One click on the pencil icon, you will get to the exact line in that file with your favorite editor (default is phpStorm)

Suggest solutions

  • Take a look at an error example. Specifically, we forgot to import an class while using it. Here’s how Ignition will display the following error message:

import-missing

Because Ignition nhìn an exception for a class not found, it will try searching by class name in other namespaces, if that class name exists in a certain namespace, it will suggest importing them.

Ignition will offer some suggestions on solutions to some common problems. For example, this is when the .blade file is not found.

invalid-view

You can add suggestions for solutions to your own exceptions. Please set your exception at FacedeIgnitionContractsProvidesSolution . It will ask you to add the getSolutions function. Here is an example of installing them.

The following is the Ignition when this error occurs

custom-solution

Looking ham vc.

Running solutions

More than just suggesting solutions, Ignition can also implement these solutions. Imagine, in case you forgot to set the app key, this is the image that Ignition will display.

app-key-missing

If you click on Generate app key button, Ignition will generate and set them to app key And Ignition it will look like this:

app-key-generated

If no other exceptions exist, the application will run without problems.

Here is a youtube link introducing Runable solution in Ignition .

Its specific installation structure might be as follows.

And this is the code for MyRunableSolution

And this is how the CustomException displayed on Ignition will be

custom-runnable-solution

The run function will be executed if the user clicksed on Fix this for me button. You may pass additional parameters from the request when this exception occurs to resolve them at runtime. It is simply getRunParameters returns an array, and it will be passed to the run function.

It looks like a falcon, but I don’t know if the getRunParameters function might be like this

Make Ignition smarter.

You can enhance exception handling by using written suggestions or runable solutions . However, sometimes you will encounter php exceptions or 3rd party software exceptions, which you cannot control. As such, Ignition provides the Solution Provider . Solution providers are classes that hook a solution process to Ignition. When the exception is fired, Ignition will receive it, and your custom solution provider will be called one time, or many solutions will be able to be called with this exception.

You can create a Stack Overflow solution provider, where you can find answers to exceptions, and treat that as a solution.

Here are some example code. This idea of ​​me too.

After a bit of research, I felt very satisfied, but the suffering version of Laravel being used, was smaller than 6.0. I asked the question, is there a way to use it in the lower version? So I researched and found this link, guys. It’s easy to crack: https://flareapp.io/docs/ignition-for-laravel/installation Support from Laravel 5.5. upwards, I tried and succeeded brothers. Each project is private, so it can’t be shown to you guys, but I think it is also delicious.

Share the news now

Source : Viblo