Files
core/app/Console/Commands/InstallAllModules.php
T

54 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
class InstallAllModules extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'install-all-modules';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Crawl /modules directory and install all modules';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$modules = File::directories(config('modules.paths.modules'));
foreach ($modules as $module) {
$moduleName = basename($module);
try {
$this->call('install-module', ['name' => $moduleName]);
} catch (\Exception $e) {
$this->line('Module ' . $moduleName . ' already installed.');
}
}
}
}