LaravelInstaller
LaravelInstaller copied to clipboard
.env not update at first
Hi everyone, i noticed a problem with the installer working on localhost. It works fine only if after saving .env details I stop and restart the application. If I try to go ahead after saving the details for the connection I'll receive: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations) .env file is updated but the procedure continue to use the old data. Any solution for it? Thanks :)
@rashidlaasri Got the same problem on my machine, clean installed win10, running php 7.3 seems like it uses the old .env data for the migrations instead of the new one
Steps to reproduce:
- Create new laravel project
- Install your installer plugin
- php artisan serve
- go to /install
- at the database step fill in something different than homestead
- click next
Working on a major update with the fix these days. Should be out soon.
@rashidlaasri Thanks... we are waiting...
I am trying to implement into my application. Facing a problem with- .env file is updating during installation but not creating any database to my localhost/phpmyadmin. What should I do?
I am trying to implement into my application. Facing a problem with- .env file is updating during installation but not creating any database to my localhost/phpmyadmin. What should I do?
I don't know if this issue still exist but one cause of this issue is file/directory permission check the base_path() where the .env file is located if it is 777 file permission
Working on a major update with the fix these days. Should be out soon.
Any solution for the local server yet? :) It still does not update .env file until the server is restarted. Awaiting a response
@simar88 Have you solved this issue? @rashidlaasri Any update on this?
I get the new value in the second request (once I refresh the page).
Hi, @ishan501 Here is how I was able to work around this is: I set a default value for key in my app.php in config directory so as to allow the app run without the .env file in your project during the installation. So the installer will be updating from the .env.example during the installation and a new .env file will be saved.
Sample of update on my app.php config file
`'key' => env('APP_KEY',"base64:ryF1edNcA3S9d4+Owf3H8OCzrJQjz8RlBFXY/R/Xji8="),`
Run Command php artisan optimize
in terminal.
I hope this help
Hi @sirdoro1, thanks for your response.
I have solved it in a different way. As I noticed it gets updated on the second request. I separated the save and check routes.
New code:
public function saveClassic(Request $input, Redirector $redirect)
{
$this->EnvironmentManager->saveFileClassic($input);
event(new EnvironmentSaved($input));
return $redirect->route('LaravelInstaller::environmentCheckConnection');
}
//checks db connection
public function checkConnection(Redirector $redirect)
{
if (!$this->checkDatabaseConnection()) {
return $redirect->route('LaravelInstaller::environment')->withErrors([
'envConfig' => 'Could not connect to the database.',
]);
}
return $redirect->route('LaravelInstaller::environment');
}
Initially, the checkDatabaseConnection method was in the saveClassic method itself.
Now it's taking new env value and is working expected :)