Issue
On laravel 10 site I need in admin area to show some info on mysql database, which is used in mysql db replication.
When I need to get mysql status I run command under mysql console :
SHOW MASTER STATUS \G
But with symfony/process library I can get and show output of linux commands, but not a command which I run under mysql console. I searched in mysql-mariadb section of the documentation : https://docs.platform.sh/guides/symfony/environment-variables.html?utm_source=symfony-cloud-sign-up&utm_medium=backlink&utm_campaign=Symfony-Cloud-sign-up&utm_content=docs#mysql-mariadb But I did not find any hints how to get output of the command.
How this can b3e domn? Some other tools ?
"laravel/framework": "^10.35.0",
"symfony/process": "^6.4",
Thanks in advance!
Solution
You can run this using DB facades , handle the result and show in your view
//in your route
Route::get('/admin/mysql-status', 'AdminController@mysqlStatus');
// in your Controller
$status = DB::select(DB::raw('SHOW MASTER STATUS'));
return view('admin.mysql_status', ['status' => $status]);
// in your view
@foreach ($status as $row)
<p>{{ $row->YourColumnName }}</p>
@endforeach
Answered By - elemes Answer Checked By - David Marino (WPSolving Volunteer)