This package can send messages to the Timber app.
timber('hi there!')
timber('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-timber
You can publish and run the migrations with:
You can publish the config file with:
php artisan vendor:publish --provider="Spatie\Timber\TimberServiceProvider" --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 Timber as well.
*/
'send_log_calls_to_timber' => true,
/*
* The port number to communicate with Timber.
*/
'port' => 23517,
];
You can pass any variable you want to timber
:
timber('a string', ['an array'], new MyClass)
All arguments will be converted to strings and will be sent to Timber.
You can disable sending to Timber by calling disable
.
timber('foo'); // will be sent to Timber
timber()->disable();
timber('bar') // will not be sent to Timber
timber()->enable();
timber('baz'); // will be sent to Timber
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 Timber
timber()->enable($i === 3);
timber('we are in the third iteration');
}
You can send all queries to Timber using logQueries
.
timber()->logQueries(); // all queries after this call will be sent to Timber
If you wish to stop logging queries, call stopLoggingQueries
.
timber()->stopLoggingQueries(); // all queries after this call will not be sent to Timber 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 Timber.
timber()->logQueries(function() {
$this->mailAllUsers(); // all queries executed in this closure will be sent to Timber
});
User::get(); // this query will not be sent to Timber
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.