I have a little annoying problem on my PhpStorm IDE (Version 2017.3.4).
So I am trying to have suggestion of my constants defined on my project. But when I am trying to Ctrl + Space there is none of my define constants.
All my constant are define like this in my project :
In a file :
$configFileDir = "configfile.php";
if (file_exists($configFileDir)) {
require_once($configFileDir);
try {
define('CONSTANT1', $MY_CONSTANT["CONSTANT1"]);
define('CONSTANT2', $MY_CONSTANT["CONSTANT2"]);
...
}
}
All my constants are in an array called $MY_CONSTANT
loaded in the file configfile.php
.
Another thing : in my project these constants are define 2 times.
What I have tried so far :
- File / Invalidate cache
- Changing PHP version in Preferences / Languages & Frameworks / PHP
If somebody have an idea this would be cool :) .
Solution :
To get the suggestions from the IDE, I just removed the try..catch
block arround the defines instructions. After that we can get the autocompletion for these constants :) . ( Big thanks to @LazyOne )
print_r($MY_CONSTANT["CONSTANT1"]);die;
insidetry
block. Do you get value of the constant ? – Himanshu Upadhyaytry..catch
block. Move it out of it and try that way. Also: youtrack.jetbrains.com/issue/WI-38507 – LazyOne