Is it possible to make a input to set database user/password in symphony at stratup of the application (like phpmyadmin) ?
I want that my application do like this :
- Welcome page (only html, no database connecion with just input for db username/password (like phpmyadmin))
- User set username/password on inputs and click ok button => the values can be set into Request/post or Session in the controller by exemple
- Symfony connect database to all application and redirect user to ‘app_index’ route
Is it possible to do it with Symphony 5 ?
Here my controller action:
public function database_login(Request $request, Connection $connection): Response
{
if ($request->isMethod('POST') && $request->request->has('dbpass')) {
$dbpass = $request->request->get('dbpass');
$params = $connection->getParams();
$params['password'] = $dbpass;
$connection->__construct($params, $connection->getDriver(), $connection->getConfiguration(), $connection->getEventManager());
$connection->connect();
return $this->redirectToRoute('app_index');
}
return new Response(
'<form method="post">
<input type="password" name="dbpass">
<button type="submit">OK</button>
</form>'
);
}
The new connection work’s fine but it lost after redirecToRoute()
function.
Can you help me ?
Thanks
Source: Symfony Questions
Was this helpful?
0 / 0