Thank you in advance,
I have one route defined like
Route::get('/registration/verify/{token}', 'UserController#verifyRegisteredEmail')->name('registration.email.verification');
I am accessing the route like
route('registration.email.verification', ['token' => $email_register_verification_token]);
when I am printing above line it is giving them out as below
http://localhost/registration/verify/87006dcc95bcf7a9ea83e523f2aa53f9
But it should be
http://localhost/{root}/registration/verify/87006dcc95bcf7a9ea83e523f2aa53f9
Try setting the proper APP_URL in .env. It only outputs the wrong value from there.
Try to set the APP_URL inside .env file, and run this command php artisan config:cache
If you have some routes with a same prefix, You can use prefix option in routes groups like this:
Route::prefix('Your Root')->group(function(){
Route::get('/registration/verify/{token}', 'UserController#verifyRegisteredEmail')->name('registration.email.verification');
});
Related
I can't seem to figure out what I'm doing wrong.
I want my application to use "np" as its default locale. So I change the locale key in config/app.php to 'np.' And when I check for the current location in my controller, it returns 'np', so it's working fine until here. Then I created a "np.json" file directly inside the lang directory, which has the following content:
{
"Candidate": "उम्मेदवार"
}
Now when I try to return the translated string using:
__('Candidate')
It returns "Candidate" instead of "उम्मेदवार", even if the current locale function still returns "np". So I ran the following commands trying to clear the cache.
php artisan optimize:clear
php artisan config:clear
php artisan cache:clear
But still, the issue persists.
You have to call the translations like <filename>.translation_string, and that file has be placed inside a folder with your language code.
In your case, create a folder inside lang called np, then place a translation file (example: mystrings.php) in it, so you have this file in a folder lang/np/mystrings.php.
Your trans file looks like
<?php
return [
'Candidate' => 'उम्मेदवार',
];
Now, you have to set the lang to your language np with app()->setLocale('np'); or you set it directly in your .env and now you can call
echo __('mystrings.Candidate');
to get your translation.
Hope it helps
I'm changing Laravel .env variable after a process, and checking that variable everytime, if it's true code doing one thing, if it's false another thing. But after changing the .env variable I have to restart with php artisan serve, I don't want to do this. Why Laravel does not read the new env variable, it changes on the .env file itself.
You shouldn't have to manipulate environment variables during runtime. If you're trying to manipulate an environment variable, you should probably instead utilize a config value. These configuration files are placed in the config/ directory of your project.
Then during runtime, you can use the following built-in config helper to get/set your config variable.
$value = config('app.timezone');
// To set configuration values at runtime, pass an array to the config helper
config(['app.timezone' => 'America/Chicago']);
$newValue = config('app.timezone');
You can read more about this process here (you can change the version to your version):
https://laravel.com/docs/5.5/configuration#accessing-configuration-values
In one of my Laravel based application, I want to include a JSON key file that is currently located in public/key/store.json
Now I want to write a constant in Laravel .env file so that I can access that file anytime I want. So, I write the following line of code:
KEY_FILE='/public/key/store.json'
But it show file path does not exist.
Can anyone tell me what's wrong in my declaration?
you should push your path in your app/config.php not in your .env
I put this in bootstrap/app.php
dump(env('STRIPE_SECRET_KEY'));
and it's coming back null even though this environment variable is set in my .env file.
I suspect that file hasn't loaded by the time bootstrap/app.php runs.
What file does run after the env files are loaded? Is there another startup file where I can put this sort of thing?
1)
You can use env() only in config files config/*.php but there are some trick. Add this code at the beginning of bootstrap/app.php:
try
{
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
}
catch (Dotenv\Exception\InvalidPathException $ignored) { }
Look here.
2) You can do it in AppServiceProvider file.
When I do a var_dump('APP_KEY') in Laravel, why does my app_key prepended with base64: as it was in the .env file? I got something like "base64:bgdhyebgehjegg" instead of just bgdhyebgehjegg.
I found out that there is a commit on Laravel that now takes care of this from The Encrypter.
https://github.com/laravel/framework/commit/370ae34d41362c3adb61bc5304068fb68e626586