How to customize constants in laravel
This article introduces the knowledge of "how to customize constants in laravel". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Constant definition scheme A:
Step1 generates constants files by path
App/config/constants.php
In the step2 constants file.
Return ['ADMIN_NAME' = >' administrator','ADMIN_NAME1' = > ['INIT' = >' 1']]
When step3 is used,
Echo Config::get ('constants.ADMIN_NAME'); echo Config::get (' constants.ADMIN_NAME1.INIT')
Constant definition scenario B:
It is added in global, because it is a global startup file ~ add pure php
1. Add require app_path (). / constants.php' to the app/bootstrap/autoload.php file
2. Define the pure PHP constant, define ('ADMIN',' administrator') in app/constants.php (create the file manually)
This is the end of "how to customize constants in laravel". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!