Skip to content

Instantly share code, notes, and snippets.

@austinheap
Forked from duellsy/artisan.php
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austinheap/10027292 to your computer and use it in GitHub Desktop.
Save austinheap/10027292 to your computer and use it in GitHub Desktop.
More polished version of @duellsy's mod to prompt for confirmation before running Laravel artisan commands on a specific environment (mainly production).
<?php
// Adding this to your app/start/artisan.php file will
// do a quick confirmation that you really do want
// to run this command when in production environment
if (php_sapi_name() == "cli" &&
App::environment() == "production")
{
echo "\033[0;31m\n";
echo <<<EOF
uuuuuuuuuuuuuuuuuuuu
u" uuuuuuuuuuuuuuuuuu "u
u" u\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$u "u
u" u\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$u "u
u" u\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$u "u
u" u\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$u "u
u" u\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$u "u
\$ \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$ \$
\$ \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$ \$
\$ \$\$\$" ... "\$... ...\$" ... "\$\$\$ ... "\$\$\$ \$
\$ \$\$\$u `"\$\$\$\$\$\$\$ \$\$\$ \$\$\$\$\$ \$\$ \$\$\$ \$\$\$ \$
\$ \$\$\$\$\$\$uu "\$\$\$\$ \$\$\$ \$\$\$\$\$ \$\$ """ u\$\$\$ \$
\$ \$\$\$""\$\$\$ \$\$\$\$ \$\$\$u "\$\$\$" u\$\$ \$\$\$\$\$\$\$\$ \$
\$ \$\$\$\$....,\$\$\$\$\$..\$\$\$\$\$....,\$\$\$\$..\$\$\$\$\$\$\$\$ \$
\$ \$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$ \$
"u "\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$" u"
"u "\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$" u"
"u "\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$" u"
"u "\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$" u"
"u "\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$" u"
"u """""""""""""""""" u"
""""""""""""""""""""
******************************************
* >>> YOU ARE ON A \033[30;33mPRODUCTION\033[0;31m SERVER <<< *
******************************************
EOF;
echo "\033[30;34mAre you sure you want to run \"\033[30;37m" . implode(" ", $_SERVER["argv"]) . "\033[30;34m\"? (yes/NO) \033[30;37m";
$line = fgets(STDIN);
echo "\n";
if(strtolower(trim($line)) != "yes")
{
echo "\033[0;33mABORTING!\033[0m\n";
exit;
}
echo "\n";
echo "\033[0;32mThank you, continuing...\033[0m\n";
}
@austinheap
Copy link
Author

Example Output:

alt text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment