Lumen Version: 5.6
PHP Version: 7.2
Database Driver & Version: SQLite 3
Steps To Reproduce:
cp .env .env.testing
SetAPP_ENV=testing
Run php artisan migrate --env=testing
Problem
Old env file configuration is executing.
First:
php artisan cache:clear
php artisan config:cache
You need to specify the environment before the migrate command.
php artisan --env=testing migrate
I found the solution myself. This feature is not there in this lumen version.
PR LINK FIX
Related
I have a Laravel project (v8.12) running on PHP 7.4.3 in a dedicated AWS instance with Ubuntu 20.04. When I try to read an environment variable from inside a job, the value is always null, but it works elsewhere. I tried to switch from supervisord to sync driver, still couldn't reach it.
Your problem could be from cache .
you can below commands for remove cache .
php artisan cache:clear
php artisan config:clear
php artisan view:clear
Run below commands
composer dump-autoload
php artisan clear-compiled
php artisan optimize
php artisan route:clear
php artisan view:clear
php artisan cache:clear
php artisan config:cache
php artisan config:clear
For Example
In your env file
SITE_NAME="My website"
Get your env variable like
$data = env('SITE_NAME');
echo $data;
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
How can I set environment variable of a php artisan command using Lumen 5.3? Laravel 5.0 says:
php artisan migrate --env=local
But in newer version documentations this section is disappeared. I run this my command like:
php artisan myCommand --env=testing
But both in my command class and bootstrap file (simply everywhere) dumping env(APP_ENV) results in local
Any suggestions?
It's as simple as
APP_ENV="production" php artisan myCommand
Or in multiple environment as
APP_ENV="production" DB_USER="foo" DB_PASSWORD="bar" php artisan myCommand
When I migrate the table, the php artisan migrate does not work.
Use composer.
Navigate to the root directory of the project. Run,
php artisan october:up
if you want to roalback you can run
php artisan october:down
Be sure to use composer in the project directory
php artisan migrate:refresh php artisan migrate:rollback php artisan migrate --force are some cmd's you could try. I don't know if this helps you otherwise please explain your question a bit more.
Go to the root directory of your project in command prompt and run these commands
To reset the current migrations if there are some php artisan migrate:reset
then run php artisan migrate