1. Go to this page and download the library: Download arcostasi/console-log library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
Console::Log("Hello\nConsole!!!"); // Displays as text with break line
Console::Log(2 + (2 * 3)); // Calculates the number and prints the result as text
Console::Log(new \DateTime()); // Displays as an Object
Console::Log(\App\Models\User::all()); // Displays as an Array
Console::Warn('This is an example of WARNING!!');
Console::Info('This is an example of INFO!');
Console::Error('This is an example of ERROR!!! Boom 💣');
use App\Models\User;
use Console;
...
Console::Debug(User::all());
use App\Models\User;
use Console;
...
Console::Trace(User::all());
use App\Models\User;
use Console;
...
Console::Table(User::all(['name', 'email']));
use Console;
...
$text = 'hello';
// This is a example with heredoc
$html = <<<HTML
<!DOCTYPE html>
<html lang="en">
<head>
<!-- ... -->
</head>
<body>
<h1>$text</h1>
<script>
console.dirxml(document.body);
</script>
</body>
</html>
HTML;
Console::DirXML($html);
Console::Clear();
Console::Assert(2 == '2', '2 not == to "2"'); // this will pass, nothing will be logged
Console::Assert(3 === '3', '3 not === to "3"'); // this fails, '3 not === to "3"' will be logged