I'm using Laravel-Localization 1.2.6 in Laravel 5.3
When I set:
hideDefaultLocaleInURL = true
It's not working.
locale is set to 'sk'
fallback_locale is set to 'sk'
But I can access both domain.app & domain.app/sk
Also when I switch language to SK language code is still in URL.
Everything else is working fine... Any suggestions?
Just clean your config cache
php artisan config:cache
Related
i'm trying to change language with laravel but it still en (fallback_locale)
locale changes successfully to another language but laravel still depends on fallback_locale
while changing fallback locale to 'ar' as example, blade prints the key as web.product.name
i tried trans('web.product.name',[],'ar'); in tinker cmd and it works fine
/config/app.php
'locale' => 'ar',
'locales' => ['en', 'ar', 'ku', 'tu'],
php artisan cache:clear does not effect
echo 'locale' anywhere returns what i set but lang still en
Have you tried clearing your cache?
php artisan config:clear
I'm upgrading Laravel to 5.2 from 5.1. When i refere to variable API_DOMAIN in .env file using $_ENV
$_ENV['API_DOMAIN']
I get an error saying Undefined index: API_DOMAIN". Am I missing something here? should i do something after composer update?
Try using the env helper instead, env('API_DOMAIN')
Run the below commands after making changes in env file. It will flush and repopulate all the env variable.
php artisan config:cache //flush all cached env variable
php artisan config:clear //repopulate all the env variable
php artisan cache:clear //flush all the cached content
You should not directly work with environment values in your application, I would create a new configuration file or use an existing one and add the value there, this way you can cache the configuration.
Lets use your API_DOMAIN as an example:
.env file
API_DOMAIN=www.mydomain.com
Config file
config/api.php for example
<?php
return [
'domain' => env('API_DOMAIN'),
];
Now you can use the config helper to use this variable in your application:
$value = config('api.domain');
You should never use the env() helper outside of config files, because when you cache your config, env() will return null.
I have these values in my .env file:
APP_IMG_PATH="/img/"
APP_IMG_LOGO="sclogo.png"
Then in my header I do this:
<img src="{!! env('APP_IMG_PATH') . env('APP_IMG_LOGO') !!}" class="navbar-logo"/>
But the log does not show and in Chrome Inspect I get
<img src(unknown) class="navbar-logo">
I tried clearing config cache and recreating it:
php artisan config:cache;
But the result is the same. Any help is appreciated.
Config caching disables env() calls. Any call to env() will return null once the config is cached.
Perhaps a poor choice by the Laravel team, but the idea is to encourage you to use config(), not env() within your code.
Instead, add new lines to your config/app.php (if that's where you choose):
'img_path' => env('APP_IMG_PATH'),
'img_logo' => env('APP_IMG_LOGO'),
Then re-create your config cache and use config('app.img_path') and config('app.img_logo') within your application.
After addig new things to env file, you need to clear your cache.
php artisan config:clear
php artisan config:cache
I want to configure my database on CI but I have a problem
How can i fix it?
I'm using CI 2.x
And
phpMyAdmin-4.6.6-english
As I can check your using wrong database settings in your database.php file.
If your php version is equals to php 5.5 or above you have to use
$db['default']['dbdriver'] = 'mysqli';
instead of
$db['default']['dbdriver'] = 'mysql';
and also put your database username and password in setting to avoid this error.
I recommend you to use codeigniter 3 the latest version .
I upgraded laravel 5.1 to 5.2, everything looks good.
But when try to access the app environment not getting what expected.
When i dd($_ENV) this is what i get
"APP_ENV" => "vagrant"
"APP_DEBUG" => "true"
"DB_HOST" => "localhost"
But When dd(\App::environment());
"production"
P.S. even I checked in tinker: dd(env('APP_ENV')) gives me "vagrant"
but dd(\App::environment()) gives me "production".
Dont you think it is odd :(
This is wierd :(
Anyone face this problem ??
you missed a step in the upgrade process:
Configuration
Environment Value
Add an env configuration option to your app.php configuration file that looks like the following:
'env' => env('APP_ENV', 'production'),
P.S. You can check the value from the artisan command:
php artisan env
Sometimes when you changed in your .env file it does not take correct values from that, the problem is due to some configuration cache.Try running following commands, hope will work
php artisan config:cache
php artisan config:clear
php artisan cache:clear