I'm trying to execute Artisan CLI command in a Laravel controller using programming conditional logic(if/else). In other words, I'm trying to execute Artisan CLI command through using HTTP request/response cycle. However, when I'm using a form submission to do this I get this error:
Spatie\DbDumper\Exceptions\DumpFailed thrown with message "The dump
process failed with exitcode 2 : Misuse of shell builtins : sh: 1:
cannot create
/var/www/html/DC_for_Rony/dc/storage/app/Laravel/dump.sql:
Permission denied
"
I've already researched everything online about this issue. Unfortunately none of them satisfied with the correct solution that I need.
DBBackupController.php(for Programming Logic, I'm only stating the function):
public function auth_bkp(Request $request){
if (Auth::user()) {
if (Auth::user()->role == 3 && $request->pass ==
'dc_for_rony') {
// dd('1');
Artisan::call(BackupDatabase::class,array());
return back()->with('yesss!!');
}else{
//dd('2');
return back()->with('sorry!');
}
}else{
}
}
config/database.php(for Configuration Issues Just the mysql driver):
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', ''),
'username' => env('DB_USERNAME', ''),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
'dump' => [
'dump_binary_path' => '/usr/bin', // only the path, so
without `mysqldump` or `pg_dump`
'use_single_transaction',
'timeout' => 60 * 5, // 5 minute timeout
'exclude_tables' => ['table1', 'table2'],
'add_extra_option' => '--optionname=optionvalue',
]
],
I'm expecting to generate the Artisan CLI command if the logic suffices. My mysqldump is already installed.Can anybody help?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire