Download the PHP package arcostasi/console-log without Composer
On this page you can find all versions of the php package arcostasi/console-log. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arcostasi/console-log
More information about arcostasi/console-log
Files in arcostasi/console-log
Package console-log
Short Description Console Log Facade for Laravel
License MIT
Homepage https://github.com/arcostasi/console-log
Informations about the package console-log
Console Log Facade for Laravel 5.x
The JavaScript console is an invaluable tool to help develop and debug our apps. With the console object and its logging methods, long are the days of calling alert() to debug and get a variable’s value. On top of that, thanks to a work in progress standard, modern browsers are finally supporting the same set of methods.
Requirements
- PHP 7.0 or higher
- Laravel 5.0 or higher
Installation
And now you can publish your config:
Add to config/app.php
Usage
Add in your blade view template:
and add Console facade in your PHP files (controllers or models):
Logging
Console::Log is the usual method we use to log values out to the console:
But we also have access to more logging methods like warn, info and error:
As you can see from the resulting console output, using the warn or error methods also gives us a stack trace:
You can also prints out objects with Debug method:
or you can also trigger a stack trace with Trace method:
Result from console output:
Table
If you feel so inclined, you can even display data in the console more neatly in a table format using Table method:
As you can see from the resulting console output, using the Table method:
Dir & DirXML
Console Dir and DirXML prints out objects in a nice formatted way:
As you can see from the resulting console output, using the dirxml method:
Clearing
You can clear the console with Clear method:
Asserting
The Assert method is an easy way to run simple assertion tests:
Counting
The Count method is used to count the number of times it has been invoked with the same provided label.
Result from console output:
Timing
As we’ve showed in this short post, you can start a timer with Time method and then end it with EndTime methos. Optionally the time can have a label:
Result from console output:
Grouping
Use Group and GroupEnd methods to group console messages together with an optional label. Notice also how a group can be nested into another one:
Result from console output:
Credits
- alligator.io (@alligatorio) A Look at the JavaScript Console API: https://alligator.io/js/console/
Licence
This library is signed under MIT License, Reproduce under it's terms.