
How to call env variable in Laravel controller
How to call env variable in Laravel controller
In this session, we are going to try to solve the "How to call env variable in Laravel controller" puzzle by using the computer language.
I have some env variable in my .env file. I want to get the value of these env variable in my Laravel controller. Is there any way to call the env variable to controller.-
Get the env variable value in controller and view blade file
env('APP_URL');
//Output
http://localhost:8000Demo code:
Route::get('/get-env', function(){ echo env('APP_URL'); });
Output may be different in your case.
You can use above code snippet to get the value of env variable and you can call it in your controller and blade (view) file.
-
config('app.url');
http://localhost:8000
This code snippet will return the app URL. Which exists in
config/app.php
file.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Run artisan command to generate key in laravel
- How to insert value to additional columns in pivot table in laravel
- How to get route name on visit URL in laravel
- Attempt to read property "avatar" on null in Laravel
- Generate unique username in Laravel
- Laravel route redirect not working
- How to return error message from controller to view in laravel
- Shorter syntax for whereHas with call back function in laravel
- Create record with unique slug in laravel
- Use of undefined constant laravel
- How to create project_user pivot table in laravel
- Convert multidimensional array to single array in Laravel
- How to get selected categories on edit record with Select2
- Call to a member function update() on null
- Add [name] to fillable property to allow mass assignment on [App\Models\Project]
- Order by multiple columns in Laravel
- How to upload image in laravel 8
- How to add foreign key in laravel using migration
- Laravel upload file with original file name
- Cannot end a section without first starting one
- OrderBy on Eloquent relationships method in Laravel
- How to include header file in laravel
- How to send ID to another page in Laravel
- How to add active class to menu item in laravel
- Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found