🔑Usage

Using Peek With Laravel

To display data in Peek, use the peek() function. It accepts anything—strings, arrays, objects, or even complex expressions. Simply pass your data to peek(), and it will appear in the app, making debugging and inspecting your code effortless and intuitive.

    
    peek("A string");

    peek(123);
    
    peek(true);
    
    peek([1, 'text']);

    peek($object);
    

peek accepts multiple arguments. Each argument will be displayed in the Peek app.

See the caller of a function

Sometimes you want to know where your code is being called. You can quickly determine that by using the caller function.

If you want to see the entire backtrace, use the trace (or backtrace).

Counting execution times

You can display a count of how many times a piece of code was called using count.

Here's an example:

This is how that looks like in Peek.

Optionally, you can pass a name to count. Ray will display a count of how many times a count with that name was executed.

Here's an example:

You may access the value of a named counter using the counterValue function.

This is how that looks like in Ray.

Measuring performance and memory usage

You can use the measure function to display runtime and memory usage. When measure is called again, the time between this and previous call is also displayed.

The measure call optionally accepts a callable. Peek will output the time needed to run the callable and the maximum memory used.

Display the class name of an object

To quickly send the class name of an object to peek, use the className function.

Showing events

You can display all events that are executed by calling showEvents (or events).

To stop showing events, call stopShowingEvents.

Alternatively, you can pass a callable to showEvents. Only the events fired inside that callable will be displayed in Peek.

Showing jobs

You can display all jobs that are executed by calling showJobs (or jobs).

To stop showing jobs, call stopShowingJobs.

Alternatively, you can pass a callable to showJobs. Only the jobs dispatch inside that callable will be displayed in Peek.

#Showing cache events

You can display all cache events using showCache

Handling models

Using the model function, you can display the attributes and relations of a model.

The model function can also accept multiple models and even collections.

Displaying mailables

Mails that are sent to the log mailer are automatically shown in peek, you can also display the rendered version of a specific mailable in Ray by passing a mailable to the mailable function.

Showing which views are rendered

You can display all views that are rendered by calling showViews.

Displaying environment variables

You can use the env() method to display all environment variables as loaded from your .env file. You may optionally pass an array of variable names to exclusively display.

Showing HTTP client requests

You can display all HTTP client requests and responses using showHttpClientRequests

To stop showing HTTP client events, call stopShowingHttpClientRequests.

Alternatively, you can pass a callable to showHttpClientRequests. Only the HTTP requests made inside that callable will be displayed in Peek.

Last updated