Using environment variables in PhpStorm
Hi all,
I am a total PhpStom noob, so please forgive my novice level.
My PHP application makes use of custom environment variables, such as $_SERVER["APPLICATION_ENV"]. These variables are set in Apache etc.
My question: How can I set them, so that PhpStorm is aware of them?
Example:
require($_SERVER["APPLICATION_PATH"] . '/application/bootloader.php');
PhpStorm can not find this required file, as it does not know of the environment variable APPLICATION_PATH. Maybe moving to $_ENV might be a solutioin?!?
Any help would be greatly appreciated.
Please sign in to leave a comment.
Hi there,
You cannot -- PhpStorm does static file analysis and therefore $_SERVER etc cannot be retrieved .. and currently you cannot manually assign any values for such array for further evaluation by PhpStorm.
In general -- this is not great approach (in terms of app portability). You better find another/better idea to include files.
For example, if your website has single point entry (e.g. every request routed via index.php) then you can declare some constant there that will contain some path .. and then use it in every include statementinstead of your $_SERVER ['CONFIG_VAR'].
If this is the ONLY way you can run your app (for whatever reason), then I can only suggest turning off appropriate inspection in PhpStorm (Settings | Inspections) for the whole project or suppress warning just for that line (via Alt+Enter when light bulb is shown).
@Garet B Claborn
It looks to me that you have missed the actual question.
The question was not "how to fill missing $_SERVER variables" but how to make PhpStorm aware of the value of the custom $_SERVER["APPLICATION_PATH"] (or any other custom key for that matter) when resolving include/require statements.
very well, retracted. apologies
how disappointing that the IDE does not resolve or offer environment configuration