-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature wish: artisan --all-domains option #14
Comments
Hi, to my knowledge (and due to the same reasons pointed out here ) there is no a safe and general way to use artisan for a command operating on all the domains. I understand very well that it would be a useful addition, but the only way I know to do this is via a bash script. Cheers, Giacomo |
Thank you Giacomo! |
HI @Scaenicus, |
Since this is technically impossible with laravel command, I coded this script to run through shell. Usage
#!/usr/bin/env php
<?php
$config = require __DIR__ . "/config/domain.php";
$domains = array_keys($config['domains']);
echo "\033[32m Run one command against all domains.\033[39m" . PHP_EOL;
if ($argv[1] ?? null) {
unset($argv[0]);
$command = implode(' ', $argv);
echo "Your command is $command" . PHP_EOL;
$input = confirm('How run command? a:All s:selective c:Cancel ');
if ($input === 'c') exit(0);
foreach ($domains as $index => $domain) {
if ($input === 'a' or (confirm("\033[96m Run against $domain ? Y/N \033[39m ") === 'y')) {
echo "\033[32m php artisan $command --domain=$domain \033[39m " . PHP_EOL;
echo shell_exec("yes | php artisan $command --domain=$domain");
}
echo PHP_EOL;
}
} else {
echo "\033[31m No command found! usage: php tenant {command}" . PHP_EOL;
}
function confirm($question)
{
echo $question . PHP_EOL;
return strtolower(rtrim(fgets(STDIN)));
} |
@SadeghPM thanks, you made my day! |
Thank you very much @SadeghPM and sorry for my delay... I will check it and include it in next version of the package (very soon) Thanks again Giacomo |
I'm sorry for not responding. Was a hard year and we never finished a general-purpose script in a sharable quality like @SadeghPM (thank you too!) |
Hi @SadeghPM, I was including your script in my package: I think it is very good, thank you! :) Cheers Giacomo |
Hi @gecche |
@SadeghPM i make some changes on your script put still i need a way to run it from the master project to the subproject so I can clear the cache on run time Usage
|
Hi, |
Maybe I haven't read the documentation enough, but is there a way to do some artisan task for all domains?
Something like:
If not I will probably develop a bash script which evaluates
php artisan domain:list
to repeat tasks for each domain.The text was updated successfully, but these errors were encountered: