55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
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()
|
|
{
|
|
// crawl all subdirectories in modules path
|
|
$modules = File::directories(config('modules.paths.modules'));
|
|
|
|
foreach ($modules as $module) {
|
|
$moduleName = basename($module);
|
|
|
|
// try to install each module
|
|
try {
|
|
$this->call('install-module', ['name' => $moduleName]);
|
|
} catch (\Exception $e) {
|
|
$this->line('Module ' . $moduleName . ' already installed.');
|
|
}
|
|
}
|
|
}
|
|
}
|