-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class RapidKitSupportCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'rapid:support'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Laravel Rapid Kit Support'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
$this->info('Welcome to Laravel Rapid Kit Support!'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Intelrx\Rapidkit\Controller; | ||
use Illuminate\Routing\Controller; | ||
use Illuminate\Support\Facades\File; | ||
use Intelrx\Rapidkit\assets\Banner; | ||
|
||
class BackupController extends Controller | ||
{ | ||
public function configureDatabaseDump(){ | ||
if (!File::exists(config_path('database.php'))) { | ||
(new Banner())->error('Database Config file does not exist'); | ||
return; | ||
} | ||
$stubPath = dirname(__DIR__, 2) . '/src/stubs/config/backupDatabaseConfig.stub';; | ||
|
||
$configPath = config_path('database.php'); | ||
$stubContent = File::get($stubPath); | ||
|
||
$configContent = File::get($configPath); | ||
if (strpos($configContent, "'dump'") === false) { | ||
$newConfigContent = preg_replace( | ||
"/('mysql' => \[.*?)(\s+\],)/s", | ||
"$1\n {$stubContent}$2", | ||
$configContent | ||
); | ||
|
||
if (File::put($configPath, $newConfigContent)) { | ||
(new Banner())->log('Backup configuration updated for MySql'); | ||
} else { | ||
(new Banner())->error('Failed to update config file'); | ||
} | ||
} else { | ||
(new Banner())->error('Configuration already exsists'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
namespace Intelrx\Rapidkit\assets; | ||
|
||
class Banner | ||
{ | ||
public function renderTitle($title) | ||
{ | ||
fwrite(STDERR, "\e[36m============================================================\e[0m\n"); | ||
fwrite(STDERR, "\e[36m$title\e[0m\n"); | ||
fwrite(STDERR, "\e[36m============================================================\e[0m\n"); | ||
} | ||
|
||
public function log($message) | ||
{ | ||
fwrite(STDERR, "\e[32m$message\e[0m\n"); | ||
} | ||
|
||
public function error($message) | ||
{ | ||
fwrite(STDERR, "\e[31m$message\e[0m\n"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'dump' => [ | ||
'dump_binary_path' => 'C:/xampp/mysql/bin/', // backup for windows | ||
// 'dump_binary_path' => '/usr/bin/', // backup for ubuntu | ||
'use_single_transaction', | ||
'timeout' => 60 * 5, // 5 minute timeout | ||
], |