Datadog collects and monitors your PHP app metrics and distributed traces in real-time with application performance monitoring. Decrease downtime and performance issues with Datadog APM by tracing requests across service boundaries and drilling into individual traces end-to-end with flame graphs. Start your 14-day trial for free today.

๐ŸŸ A package to execute a random artisan command

Original โ€“ by Freek Van der Herten โ€“ 1 minute read

Aren't you tired of having to think about which artisan command to execute? The spatie/laravel-random-command package takes that pain away. It provides a random command that will pick a random command and execute it.

This is how you can unleash the power of the random command. Just execute it and don't look back!

php artisan random

Let's take a look at how such greatness is achieved. Here's the code of the RandomCommand.

public function handle()
{
     $this->confirm('You are about to execute a random command. Are you sure you want to do this?');

    $allCommands = $this->getApplication()->all();
  
    $commandString = collect($allCommands)->keys()->random();
  		
    $this->info("Executing command: `{$commandString}`");

    // ๐Ÿงจ๐Ÿงจ๐Ÿงจ
    Artisan::call($commandString, [], $this->output);
}

We don't recommend installing this in your production environment. Or your local environment. In fact it might be best not to install it at all.

Stay up to date with all things Laravel, PHP, and JavaScript.

Follow me on Twitter. I regularly tweet out programming tips, and what I myself have learned in ongoing projects.

Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

Comments

Webmentions

Chris Smiles liked on 2nd April 2020
Jonas Pardon liked on 2nd April 2020
Stijn Vanouplines liked on 2nd April 2020
Spatie retweeted on 1st April 2020
Magnus Sรถderling liked on 1st April 2020
Chris Hardinge liked on 1st April 2020
Matthew Poulter liked on 1st April 2020
Scott Zirkel liked on 1st April 2020
Freek Van der Herten replied on 1st April 2020
Lol, weโ€™re currently building a couple of bigger real packages. But the 5 minutes spent on this one were fun!
Martin Bean replied on 1st April 2020
So has @spatie_be cornered the market and built every useful package there is to build, and are now moving on to building โ€œtoyโ€ and dummy packages like this? ๐Ÿ˜…
Alexander Six liked on 1st April 2020
Brandon Surowiec liked on 1st April 2020
Alex Elkins liked on 1st April 2020
WaveHack liked on 1st April 2020
Wyatt liked on 1st April 2020
Steve Thomas ๐Ÿคฏ liked on 1st April 2020
James liked on 1st April 2020
Peter Sowah liked on 1st April 2020
Musa ๏ฃฟ liked on 1st April 2020
Niels liked on 1st April 2020
Mohammed Ghunaim liked on 1st April 2020
Ray Blair liked on 1st April 2020
Wouter Brouwers liked on 1st April 2020
Travis Elkins liked on 1st April 2020
Freek Van der Herten replied on 1st April 2020
๐Ÿ˜ฌ๐Ÿ˜ฌ๐Ÿ˜ฌ
Wouter replied on 1st April 2020
deploy:production
Dฤvis replied on 1st April 2020
Joren Van Hocht replied on 1st April 2020
๐Ÿ˜…
Pv Ledoux liked on 1st April 2020
Mattias Geniar retweeted on 1st April 2020
PHP Synopsis retweeted on 1st April 2020
Didik Tri Susanto liked on 1st April 2020
Tauseef Shah liked on 1st April 2020
Sebastian De Deyne liked on 1st April 2020
illmatix liked on 1st April 2020
Faisal ahmed liked on 1st April 2020
Andy Hartnett liked on 1st April 2020
ServerPilot liked on 1st April 2020
Jeremy Nikolic liked on 1st April 2020
Mattias Geniar liked on 1st April 2020
warren liked on 1st April 2020
Ken V. liked on 1st April 2020
Tally Schmeits liked on 1st April 2020
Owen Voke liked on 1st April 2020
Khorshed Alam liked on 1st April 2020
Mladen Daniฤ‡ liked on 1st April 2020
Peter Brinck ๐Ÿค˜ liked on 1st April 2020
Geoffrey van Wyk replied on 1st April 2020
Random? Sounds dangerous.
Ken V. replied on 1st April 2020
Oh, look what day it is... LMAO ๐Ÿ’ฃ
hans ๐Ÿ‘€ replied on 1st April 2020
Artisan Roulette
Stuart Jones retweeted on 1st April 2020
Jeroen Nijhuis liked on 1st April 2020
Florian Voutzinos โšก liked on 1st April 2020
hans ๐Ÿ‘€ liked on 1st April 2020
Mike Gatward liked on 1st April 2020
Stuart Jones liked on 1st April 2020
Freek Van der Herten replied on 1st April 2020
Sure ๐Ÿ™‚
Shreyansh replied on 1st April 2020
Lmao is that your version of a mild April Fool joke?
Pascal Baljet replied on 1st April 2020
Any interest in a PR that always adds the --force flag?