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
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.
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,
];
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.
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');
}
You can send all queries to Ray using logQueries
.
ray()->showQueries(); // all queries after this call will be sent to Ray
If you wish to stop logging queries, call stopLoggingQueries
.
ray()->stopShowingQueries(); // 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()->showQueries(function() {
$this->mailAllUsers(); // all queries executed in this closure will be sent to Ray
});
User::get(); // this query will not be sent to Ray
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.