name file | size | edit | permission | action |
---|---|---|---|---|
.env | 2733 KB | December 22 2024 06:20:07 | 0644 | |
404.html | 58370 KB | November 20 2024 15:32:22 | 0644 | |
502.html | 58368 KB | November 20 2024 15:32:22 | 0644 | |
Modules | - | December 11 2024 21:02:56 | 0755 | |
README.md | 4158 KB | February 14 2023 12:31:56 | 0644 | |
app | - | December 11 2024 17:57:48 | 0755 | |
artisan | 1686 KB | February 14 2023 12:31:56 | 0644 | |
bootstrap | - | December 11 2024 20:23:36 | 0755 | |
composer.json | 3761 KB | December 11 2024 22:15:00 | 0644 | |
composer.lock | 512048 KB | December 11 2024 22:13:28 | 0644 | |
config | - | June 15 2025 02:09:36 | 0755 | |
database | - | December 05 2024 20:18:12 | 0755 | |
dfsdf dfds fd fds findex.html | 1420 KB | November 20 2024 15:32:24 | 0644 | |
error_log | 17050586 KB | July 18 2025 18:38:34 | 0644 | |
firoz | - | December 23 2024 13:24:46 | 0755 | |
index.php | 1667 KB | December 14 2024 05:20:36 | 0644 | |
lang | - | December 11 2024 21:02:48 | 0755 | |
modules_statuses.json | 472 KB | November 20 2024 15:32:24 | 0644 | |
mpos | - | March 31 2025 02:36:31 | 0755 | |
package.json | 226 KB | February 14 2023 12:31:56 | 0644 | |
phpunit.xml | 1146 KB | February 14 2023 12:31:56 | 0644 | |
public | - | March 31 2025 02:36:31 | 0755 | |
resources | - | December 11 2024 21:10:22 | 0755 | |
routes | - | June 15 2025 02:09:31 | 0755 | |
storage | - | December 11 2024 21:12:44 | 0755 | |
tests | - | December 05 2024 20:18:12 | 0755 | |
vendor | - | December 11 2024 22:13:30 | 0755 | |
vite.config.js | 263 KB | February 14 2023 12:31:56 | 0644 |
Icons mode
Labels mode
## Installation (PHP 7.4+) ```bash composer require shalvah/clara ``` ## Using Clara ```php $output = clara('myappname'); $output->info("Installing package"); $output->debug("Attempt 3 of 5"); $output->warn("The file does not exist."); $output->error("Something went wrong!"); $output->success("Done. Go and be awesome."); ``` ### Picking a mode By default, Clara uses "icons" mode—the output is coloured differently by output type and an emoji is added (as in the first screenshot above). If you prefer, you can switch to "labels" mode: ```php $output = clara('myappname', \Shalvah\Clara\Clara::MODE_LABELS); // The default $output = clara('myappname', \Shalvah\Clara\Clara::MODE_ICONS); ``` In labels mode, (the second screenshot above), the emojis are still present, but the output types are written out, and the main output message is not coloured. ### Disabling colours and emojis If you'd like to output a line of text without the extra formatting provided by the functions above, you can use the `->line()` method instead. ### Customising the colour palette You can also customise the colours Clara uses for each type, by passing in an array as the third argument, containing your preferred colours: ```php $output = clara('myappname', \Shalvah\Clara\Clara::MODE_ICONS, [ 'info' => 'blue', ]); ``` See [the Symfony docs](https://symfony.com/doc/current/console/coloring.html) for details about supported colours. ## Toggling debug output It's common practice to include a verbose flag (`--verbose`) in your CLI app that lets you show additional (debug) output to the user. With Clara, you can easily enable or disable debug logging: ```php $isVerbose = $this->getFlag('verbose'); // If $isVerbose is true, // Clara won't print or capture any debug logs $app1 = clara('app1')->showDebugOutput($isVerbose); $app1->debug("App 1 - Output 1"); // You can also toggle debug output manually $app1->hideDebugOutput(); $app1->debug("App 1 - Output 2"); $app1->showDebugOutput(); $app1->debug("App 1 - Output 3"); ``` Note that by default, Clara will show all output. ## Muting output Sometimes when running your app's tests, you don't want to clutter your console with the output messages. You can turn off Clara's output by using the `mute()` and `unmute` static methods. To mute or unmute a specific app, pass in the app name. ```php $output1 = clara('myapp1'); $output2 = clara('myapp2'); // Mute only output from "myapp1" Clara::mute('myapp1'); // Won't be printed. $output1->info("Installing package"); // Will be printed $output2->info("Installing package"); Clara::mute(); // Mute all apps Clara::unmute("myapp1"); // Unmute myapp1 Clara::unmute(); // Unmute all apps ``` ## Showing only your app's output. Imagine your app includes another app that uses Clara. By default, the output from all apps will be shown. You can turn off output for all apps but yours by calling `->only()`. ```php // SHow only output from mymainapp $output1 = clara('mymainapp')->only(); // This is equivalent to doing: Clara::mute(); Clara::unmute('yourappname'); ``` ## Capturing the output Sometimes you need to assert that your app printed what you expect. An easy way is to use output capturing. ```php Clara::startCapturingOutput('myapp1'); // Clara will start capturing output from myapp1 $output1 = clara('myapp1'); $output1->warn("Going to fail"); $output1->error("Failed"); $capturedOutput = Clara::getCapturedOutput('myapp1'); // $capturedOutput = [ // "⚠