For some reason when I do dump(app()->getLocale()); it is returning fr when it should be en.
In my config/app.php I have the following:
'timezone' => 'Europe/London',
'locale' => 'en',
'fallback_locale' => 'en',
I have cleared my cache numerous times with php artisan config:clear and php artisan cache:clear, I have restarted my server but app()->getLocale() always returns fr.
Anyone know why this is?
I am using Laravel 5.6 and PHP 7.
Related
After changing app/config/app.php FROM: 'timezone' => 'UTC', which is the default TO: 'timezone' => 'Europe/Vilnius', and still getting wrong date output. Also I changed php.ini file
[Date]
date.timezone=Europe/Vilnius
and restarted apache server, still getting wrong date output.
Any idea how to solve this?
You can set your Application Time Zone by configuring app.php file in config folder. To change time zone
'timezone' => 'Europe/Vilnius'
And clear the config cache execute this command :
php artisan optimize:clear
You do not have the privileges to execute that command, you can delete the cached config file.
It is located at bootstrap/cache/config.php.
In order to reflect your timezone related changes of your config file then kindly ensure that you have cleared your cache. You can use the following command set for your reference:
php artisan cache:clear
php artisan config:cache
php artisan config:cache
Try to clear the config cache:
php artisan optimize:clear
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.
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
I am changing the timezone into Asia/Singapore at config/app.php, but when I try to do a date("Y-m-d H:i:s"); the result is still in UTC.
Is there anything in Laravel that overrides that timezone that I set at config/app.php ?
Just do this:
'timezone' => 'Asia/Singapore'
in config/app.php file and run this 3 command:
php artisan cache:clear
php artisan view:clear and
php artisan config:cache
Hope this helps you!!
Add this in config/app.php file:
'timezone' => 'Asia/Singapore'
After, run this command:
php artisan config:cache
At least in the generated application skeleton of Laravel 5.8, maybe other versions too, the timezone setting in config/app.php is
'timezone' => 'UTC',
so it will ignore an APP_TIMEZONE in the .env file.
So put an e.g. APP_TIMEZONE='Europe/Berlin' in .env and modify the line in config/app.php to this:
'timezone' => env('APP_TIMEZONE', 'UTC')
Or, when it's sure local, staging and production all run in the same timezone - change only the line in config/app.php to:
'timezone' => 'Europe/Berlin',
Searching using the TNTSearch driver works in a Homestead environment however on production it returns error: the below error,
Symfony\Component\Debug\Exception\FatalThrowableError: Class
'AlgoliaSearch\Version' not found on
vendor/laravel/scout/src/EngineManager.php:31
However my .env has SCOUT_DRIVER=tntsearch and the config file scout.php has:
'driver' => env('SCOUT_DRIVER', 'tntsearch'),
'tntsearch' => [
'storage' => storage_path(),
'fuzziness' => env('TNTSEARCH_FUZZINESS', false),
'fuzzy' => [
'prefix_length' => 2,
'max_expansions' => 50,
'distance' => 2
],
'asYouType' => false,
'searchBoolean' => env('TNTSEARCH_BOOLEAN', false),
]
The problem is that I am not using Algolia search and my composer file has Scout and TNTSearch driver. The search works in my local Homestead environment just not on the production server.
Confirm that SCOUT_DRIVER=tntsearch has been added to your .env file.
For me personally, I had added SCOUT_DRIVER=tntsearch to my local .env file, but not my .env file for the environment with the issue. Don't forget to run php artisan config:clear after adding the env var.
Thanks to #m33bo for pointing me in the right direction!
I worked it out, I had uploaded my project but for some reason the .index file that is needed sync'd but did not work. If this happens to you on live make sure you Git or SVN or whatever the index or run php artisan scout:import App\\Your\\Model