For example, I have DB_DATABASE=new_db in my .env file and the same as the config/database.php file but still showing error of Unknown database: 'older_database_name'. Please help. Thanks.
Anyway I migrated from MAMP to XAMPP..
restart the server if any changes on .env
try php artisan config:cache and php artisan cache:clear
Related
I'm having this error on cpanel...
$products = products::inRandomOrder()->take(3)->get();
Caused by the above line of code.
I've tried to tried editing my .env file and everything there is as it should be..
I even tried to edit the config/database.php file which I didn't have to edit on my local host.
I also tried running this commands
php artisan route:cache
php artisan view:cache and
php artisan config:cache
Please assist with a different solution
Thank you in advance!!!
Check your .env file to be sure that you have the correct database credentials in there. If you do and are still getting the error, clear the the config cache with either php artisan config:clear or php artisan config:cache and try it again
I use Laravel 6.2 with valet and PHP 7.3.12
The problem is I want to change DB_DATABASE=laravel to DB_DATABASE=something_else in .env file
but it doesn't reload the new .env value at all
I have already tried this command:
php artisan config:clear
php artisan config:cache
but it still doesn't change at all.
I even try to add a new key to .env file and query it in Tinker and the new key doesn't add as well.
After completion of .env edit, You can clear the configuration cache with the following artisan command: php artisan config:cache
Use php artisan key:generate it will generate the new key to your .env file
NOTE: If there is still error then you do not need your restart computer just try this:
If you are using the PHP's default web server (eg. php artisan serve) you need to restart your server
OR
If you have used XAMPP then restart your Apache server
I just restart my computer at first it doesn't work then I did
php artisan config:cache and it works now.
whenever you want to change content .env file
run php artisan cache:clear command to get newly added values
Restarting you computer has nothing to do with it.
If you are working on a local environment then please stop your development server by pressing ctrl+c and then restart the application by running php artisan serve.
I am following this tutorial here https://www.youtube.com/watch?v=Jbt5bEgv_QM and got stuck in the php artisan migrate part because of this issue. I'm not sure if it's compatibility issue or something. I am fairly new to laravel.
Here's the database.php file and .env file.
UPDATE: i managed to perform the migration using the solutions provided by the user PHP. However, i couldn't find the table in my phpMyAdmin. do i need to change mySQL root password for that? i have actually set the password but in .env and database.php files i left it blank because the migration works that way. if i set the actual password in both files, I'd get access denied error.
Here's the migration files...
php artisan migrate:rollback then run php artisan migrate.
If you make changes to your migration files, simply run php artisan migrate:refresh
1)First you have to Create your related Database.
2)Then:php artisan cache:clear
3)Now run php artisan migrate:install
I have a problem with my project laravel 5.7. I have developed it locally and all is well but once sent to my server online I have this error: view [auth.login] not found.
Ran into the same problem. I noticed three things;
A message while booting homestead about virtualbox guest-tools being out of sync between host and guest. There could be a problem with paths. I fixed that issue with the help of this here
The Laravel view [auth.login] not found on server page displayed the path of the host machine and not of the vagrant-guest.
bootstrap/cache/config.php also displayed paths from the host and not the guest.
Renaming/deleting (or artisan cache:clear) the config.php only gave errors (Laravel Error “Unable to load the ”app“ configuration file”).
I fixed the issue by correcting the paths in config.php manually to the correct path in vagrant.
Run following commands on your server.
it might solve your problem.
php artisan config:clear
php artisan cache:clear
php artisan view:clear
php artisan route:cache
php artisan optimize
or
composer dump-autoload -o
if you are in develop mode you can run:
php artisan config:clear
or if you are in product mode you can run:
php artisan config:cache
notice: when you use second, config clear and cache again and you force to repeat command for other changes.
This frequently happens in my Laravel 5 app where sometimes .env variables cannot be read.
I have the following in my .env file:
STRIPE_SECRET=sk_test_mykey
STRIPE_KEY=pk_test_mykey
After clearing all the cache using all of these commands I still cannot access the STRIPE_SECRET variable:
php artisan config:clear
php artisan cache:clear
php artisan config:cache
composer dump-autoload
I have tried in my controller using env('STRIPE_SECRET') and have also tried in tinker:
Any one know why this happens?
If you are running your server using php artisan serve.
You have to restart your server because built in server cache all the .env variables in its memory.
Just run this: php artisan config:clear
have you restarted your artisan server if not restart it and if you are using a virtual machine like vagrant try to get out of your machine and reload it using
vagrant reload