After setting up your Laravel Project, you might want to add your custom environment variable.
- Create or Add Laravel Variable/s located at
- On the terminal run
$ php artisan config:clear$ php artisan config:cache
If you execute the
config:cache command during your deployment process, you should be sure that you are only calling the .env function within your configuration files.
Once the configuration has been cached, the .env file will not be loaded and calls to the env function will return null.
- Go to your config folder and update
- Add your config object
- Go to your terminal
- Create a Laravel class by running
php artisan make:controller BlogController
- On your created controller.
i.e BlogController.php add the following.
What happened here?
- We’ve used
- Created class function
Thanks for reading and following along.
I hope that this blog will give value to you at some point. Please feel free to reach out if you have any questions.