I am using YII2 framework in netbeans, every time my project is deployed to the web server I have to change the url to that of the web server from localhost.
Therefore,
Created a config.php file in the controller folder
define("LOCAL", "http://localhost");
define("WEB", "http://website.com");
global $environment;
$environment= LOCAL; //change to WEB if you're live
Every file that needs it, put this at the top
include_once(dirname( __FILE __)."/config.php");
and every time the url is needed in the code call it using
echo $environment;
But I get the error that $environment is not defined. What am I doing wrong?
Reference How to implement absolute URLs on localhost and web server?