Laravel 5.6 Application In Production - php

When am trying to migrate anything , then every-time it's asking me about
Do you want to run ".env" instead? (yes/no) [no]:
I added .env file in my project. also i tried to solve this problem with this below changes :
config/app.php
'.env' => env('APP_ENV', 'development'),
'debug' => env('APP_DEBUG', true),
.env file below :
APP_ENV=local
APP_DEGUG = true
i also tried to fix this problem with
php artisan config:clear
after this
php artisan key:generate
Nothing changes when i checked this current mode by :
php artisan env
It's showing me
Current application environment: production
how to solve this ?

I had this problem too, and these steps helped me:
clear config
php artisan config:clear
after this php artisan key:generate
now cmd say me its local
php artisan env

There's a typo:
Not:
'.env' => env('APP_ENV', 'development'),
But:
'env' => env('APP_ENV', 'development'),
without dot before env

Related

Laravel says application is in production but APP_ENV is local

My Laravel .env:
APP_ENV=local
APP_KEY=base64:7HjBWArUX989c8K87678687m2+6786876hs=
APP_DEBUG=true
APP_URL=http://localhost
...
I get the following message if I do php artisan env.
Current application environment: production
Even if I set the default environment to local in the app.php config file, the application still think it is in production. This is driving me nuts. Anyone knows why this is happening and how to fix it? I have run the clean cache commands, optimize commands, etc. I deleted the bootstrap folder content manually, and still nothing.
Are use already run:
php artisan config:cache
php artisan config:clear
?
Update
In my opinion, there are only two reasons why you get production. 1) Something is wrong in your config/app.php in this line: 'env' => env('APP_ENV', 'production'), 2) Or something is broken in your .env file. Make sure you really have an .env file. If there is nothing wrong in your env file. And if in your app.php file this line is correct: 'env' => env('APP_ENV', 'production')
In my case, despite clearing the cache, my app env wasn't changing. I realized when I stopped php artisan serve and started it again the change in my .env file was reflected.
As to why that's the case I don't know yet, I will update this once I find out why.

Laravel database still use old name after .env changed

Edit:
php artisan config:cache work nice, but now I got other problem.
the URL giving me Error 500
I upload a project to a new subdomain area after I changed .env file
when I open URL I still got an error with the old database and user
I tried to check online with the .env file but - I don't know where he stored this database, I tried to see where is this name with ctrl+f but - nothing found
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=faceterc_hot
DB_USERNAME=faceterc_hot
DB_PASSWORD=testpro
I expect to get the same error maybe but not with the old database name.
and this gives me a indicate that maybe the file or something not changed or he using the other details from I don't know where
Good, practice for, If you change in a .env file first restart the server using below command.
php artisan serve
then after run below more command for clear old cache and config.
composer dump-autoload
php artisan config:cache
php artisan config:clear
You can simply do a
php artisan config:cache
In case you are on a shared hosting, you can change the values in config/database.php to only use the set values in your .env. Setting it like this will make sure, it only use the .env values.
mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST'),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
php artisan config:clear Solve the problem with DATABASE error
just ran :
php artisan config:clear
with ssh at the main folder.
Just execute
php artisan config:cache
as the laravel cache's the environment files rather than accessing the data from it on every request.
It's always a good practice to run these couple of commands when you change any environment related variable:
php artisan config:clear
php artisan cache:clear
Execute these commands:
php artisan config:cache
php artisan route:cache
php artisan optimize
That will clear your env cache and it should do.

env values from Linux not loaded by Laravel config app

Some time ago I asked about setting env settings and how to properly use them. I was quickly pointed to a comparable question and I found out that indeed it was bad practice to use env('KEY') throughout your code.
So now I am in the process of migrating my env settings to config/app.php.
However, if I play with Tinker, the env variables from Linux are not loaded by Laravel. For instance, if I place:
'test' => 'testing123',
within the config/app.php
and do a
sudo php artisan config:cache
and employ Tinker
config('app.test');
=> "testing123"
So that seems to work. However, if I place the following
'test' => env('DB_PORT'),
and do a
sudo php artisan config:cache
and test this with tinker:
config('app.test');
=> null
But when I am in the console and use:
env|grep DB_PORT
I see the right value for the DB_PORT key. I am supplying these in AWS frontend, these properties are then passed in the application as environment properties.
Anyone any idea why these are not imported/loaded correctly?
php artisan config:clear
Or you can just manually delete bootstrap/config.php, which is what artisan does after all.
See: vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigClearCommand.php

Laravel 5.5 Queue: No connector for []

I have two websites running identical laravel 5.5 project. In fact both websites hosted on the same server. One of them works, another one has troubles with queues. I have double-checked everything.
.env:
...
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=database
QUEUE_DRIVER=database
...
conf/queue.php
'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],
I do have empty jobs table as well.
Whenever I do try to run queues I'm getting an error
php artisan queue:work --daemon
In QueueManager.php line 172:
No connector for []
Please check the config queue drive setting. If use Redis, you can use php artisan tinker check
current the config.
Check command queue:
php artisan queue:work redis --queue=QUEUE_NAME --tries=3 --memory=128 --timeout=300
Check job listen by command line:
ps aux | grep php
I just had to specify a "connection" (database for my case) after queue:work command like below:
php artisan queue:work database --queue=Q_NAME
and the error disappeared!
Hi I encountered the same problem and couldn't find the solution but I followed laravel deploy optimizations, like cache config, view and routes which result into this. (I am not sure why).
I followed these and it worked like magic. (I don't know why it worked)
php artisan config:clear
php artisan route:clear
php artisan view:clear

localhost:8000 keeps on loading without any error or proper output

I am only learning laravel, and i am unable to load my laravel homepage on localhost:8000, from i long time it was going fine, but today i updated my composer and updated entry of :
config/app.php
in aliases::
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
in providers::
Collective\Html\HtmlServiceProvider::class,
and composer.jason file:
in require::
"laravelcollective/html": "~5.0"
now,
localhost:8000 is causing errors. It is not showing any error but it just continues to load.
I think this issue is with clearing cache. You can run following command to clear cache:
php artisan config:cache
php artisan config:clear
php artisan cache:clear
Hope this answer will help you well!
create .env file(copy from .env.example) and set
APP_DEBUG=true
APP_LOG_LEVEL=debug
Try to clean your access.log and error.log files in your Apache server logs folder (mine is here: c:\Apache\Apache2.2\logs\)

Categories