Skip to content

Latest commit

 

History

History
142 lines (92 loc) · 3.88 KB

README.md

File metadata and controls

142 lines (92 loc) · 3.88 KB

Easily debug Laravel apps

Latest Version on Packagist GitHub Tests Action Status Total Downloads

This package can send messages to the Ray app.

ray('hi there!')
ray('I am big and green')->green()->large()

Here's how that looks like in the app.

TODO: add screenshot

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

composer require spatie/laravel-ray

You can publish the config file with:

php artisan vendor:publish --provider="Spatie\Ray\RayServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    /*
     * When enabled, all things logged to the application log
     * will be sent to Ray as well.
     */
    'send_log_calls_to_ray' => true,

    /*
     * The port number to communicate with Ray.
     */
    'port' => 23517,
];

Usage

You can pass any variable you want to ray:

ray('a string', ['an array'], new MyClass)

All arguments will be converted to strings and will be sent to Ray.

Enabling and disabling logging

You can disable sending to Ray by calling disable.

ray('foo'); // will be sent to Ray

ray()->disable();

ray('bar') // will not be sent to Ray

ray()->enable();

ray('baz'); // will be sent to Ray

You can pass a boolean to enable. This can be handy when you want to log only one iteration of a loop.

foreach (range(1, 3) as $i) {
   // only things in the third iteration will be sent to Ray
   ray()->enable($i === 3);
    
   ray('we are in the third iteration');
}

Logging queries

You can send all queries to Ray using logQueries.

ray()->logQueries(); // all queries after this call will be sent to Ray

If you wish to stop logging queries, call stopLoggingQueries.

ray()->stopLoggingQueries(); // all queries after this call will not be sent to Ray anymore

Alternatively to manually starting and stopping listening for queries, you can also pass a closure to logQueries. Only the queries executed inside the closure will be sent to Ray.

ray()->logQueries(function() {
    $this->mailAllUsers(); // all queries executed in this closure will be sent to Ray
}); 

User::get(); // this query will not be sent to Ray

Testing

composer test

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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